Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Streamline Markdown notification rendering (#48162)
Nicolas Le Camc9dafd267450
diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex 157637dc8cf..124904fec05 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<F>() whereF: 'static + Send + Sync + Fn(&mut Window, &mut Context<MessageNotification>),{- 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<KeyBinding>) {