From 89c184a26fa40c237e64a63fa7a4830002bc5c96 Mon Sep 17 00:00:00 2001 From: Simon Pham Date: Fri, 30 May 2025 15:29:52 +0700 Subject: [PATCH] markdown_preview: Fix release notes title being overridden (#31703) Closes: #31701 Screenshot: image Release Notes: - Fixed in-app release notes having an incorrect title --------- Co-authored-by: Gilles Peiffer --- crates/auto_update_ui/src/auto_update_ui.rs | 2 +- .../markdown_preview/src/markdown_preview_view.rs | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/auto_update_ui/src/auto_update_ui.rs b/crates/auto_update_ui/src/auto_update_ui.rs index 07c1821588..fa44df7542 100644 --- a/crates/auto_update_ui/src/auto_update_ui.rs +++ b/crates/auto_update_ui/src/auto_update_ui.rs @@ -91,7 +91,7 @@ fn view_release_notes_locally( let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); - let tab_content = SharedString::from(body.title.to_string()); + let tab_content = Some(SharedString::from(body.title.to_string())); let editor = cx.new(|cx| { Editor::for_multibuffer(buffer, Some(project), window, cx) }); diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs index a60934283a..c9c32e216a 100644 --- a/crates/markdown_preview/src/markdown_preview_view.rs +++ b/crates/markdown_preview/src/markdown_preview_view.rs @@ -36,7 +36,7 @@ pub struct MarkdownPreviewView { contents: Option, selected_block: usize, list_state: ListState, - tab_content_text: SharedString, + tab_content_text: Option, language_registry: Arc, parsing_markdown_task: Option>>, } @@ -130,7 +130,7 @@ impl MarkdownPreviewView { editor, workspace_handle, language_registry, - "Markdown Preview".into(), + None, window, cx, ) @@ -141,7 +141,7 @@ impl MarkdownPreviewView { active_editor: Entity, workspace: WeakEntity, language_registry: Arc, - tab_content_text: SharedString, + tab_content_text: Option, window: &mut Window, cx: &mut Context, ) -> Entity { @@ -343,7 +343,9 @@ impl MarkdownPreviewView { ); let tab_content = editor.read(cx).tab_content_text(0, cx); - self.tab_content_text = format!("Preview {}", tab_content).into(); + if self.tab_content_text.is_none() { + self.tab_content_text = Some(format!("Preview {}", tab_content).into()); + } self.active_editor = Some(EditorState { editor, @@ -494,7 +496,9 @@ impl Item for MarkdownPreviewView { } fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString { - self.tab_content_text.clone() + self.tab_content_text + .clone() + .unwrap_or_else(|| SharedString::from("Markdown Preview")) } fn telemetry_event_text(&self) -> Option<&'static str> {