@@ -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)
});
@@ -36,7 +36,7 @@ pub struct MarkdownPreviewView {
contents: Option<ParsedMarkdown>,
selected_block: usize,
list_state: ListState,
- tab_content_text: SharedString,
+ tab_content_text: Option<SharedString>,
language_registry: Arc<LanguageRegistry>,
parsing_markdown_task: Option<Task<Result<()>>>,
}
@@ -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<Editor>,
workspace: WeakEntity<Workspace>,
language_registry: Arc<LanguageRegistry>,
- tab_content_text: SharedString,
+ tab_content_text: Option<SharedString>,
window: &mut Window,
cx: &mut Context<Workspace>,
) -> Entity<Self> {
@@ -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> {