From c9dafd2674506f75012851bd498c353287c944ba Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Mon, 16 Feb 2026 14:31:44 +0100 Subject: [PATCH] Streamline Markdown notification rendering (#48162) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Brought the Markdown notification rendering up to date with how Markdown is used in the Agent panel and REPL. Removed async parsing overhead and simplified the code by using the markdown crate API directly. This is preparatory work, my ultimate goal is to make markdown_preview use markdown to parse and render md to [fix not being able to select and copy content](https://github.com/zed-industries/zed/issues/16727) |Current|Now| |-|-| |Capture d’écran du 2026-02-01
22-39-39|Capture d’écran du 2026-02-01
22-37-16| Release Notes: - N/A --- crates/zed/src/zed.rs | 57 +++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 157637dc8cfaa604e8c068eb12c2430f14d447e4..124904fec059005a961fe962ab81cf01f8e4d482 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -43,6 +43,7 @@ use language::Capability; use language_onboarding::BasedPyrightBanner; use language_tools::lsp_button::{self, LspButton}; use language_tools::lsp_log_view::LspLogToolbarItemView; +use markdown::{Markdown, MarkdownElement, MarkdownFont, MarkdownStyle}; use migrate::{MigrationBanner, MigrationEvent, MigrationNotification, MigrationType}; use migrator::migrate_keymap; use onboarding::DOCS_URL; @@ -1759,48 +1760,28 @@ fn show_markdown_app_notification( ) where F: 'static + Send + Sync + Fn(&mut Window, &mut Context), { - let parsed_markdown = cx.background_spawn(async move { - let file_location_directory = None; - let language_registry = None; - markdown_preview::markdown_parser::parse_markdown( - &message.0, - file_location_directory, - language_registry, - ) - .await - }); + let markdown = cx.new(|cx| Markdown::new(message.0.into(), None, None, cx)); + let primary_button_on_click = Arc::new(primary_button_on_click); - cx.spawn(async move |cx| { - let parsed_markdown = Arc::new(parsed_markdown.await); + show_app_notification(notification_id, cx, move |cx| { + let markdown = markdown.clone(); let primary_button_message = primary_button_message.clone(); - let primary_button_on_click = Arc::new(primary_button_on_click); - cx.update(|cx| { - show_app_notification(notification_id, cx, move |cx| { - let workspace_handle = cx.entity().downgrade(); - let parsed_markdown = parsed_markdown.clone(); - let primary_button_message = primary_button_message.clone(); - let primary_button_on_click = primary_button_on_click.clone(); - cx.new(move |cx| { - MessageNotification::new_from_builder(cx, move |window, cx| { - image_cache(retain_all("notification-cache")) - .child(div().text_ui(cx).child( - markdown_preview::markdown_renderer::render_parsed_markdown( - &parsed_markdown.clone(), - Some(workspace_handle.clone()), - window, - cx, - ), - )) - .into_any() - }) - .primary_message(primary_button_message) - .primary_icon(IconName::Settings) - .primary_on_click_arc(primary_button_on_click) - }) + let primary_button_on_click = primary_button_on_click.clone(); + + cx.new(move |cx| { + MessageNotification::new_from_builder(cx, move |window, cx| { + image_cache(retain_all("notification-cache")) + .child(div().text_ui(cx).child(MarkdownElement::new( + markdown.clone(), + MarkdownStyle::themed(MarkdownFont::Editor, window, cx), + ))) + .into_any() }) - }); + .primary_message(primary_button_message) + .primary_icon(IconName::Settings) + .primary_on_click_arc(primary_button_on_click) + }) }) - .detach(); } fn reload_keymaps(cx: &mut App, mut user_key_bindings: Vec) {