Repository navigation
markdown_preview: Show directory for preview tabs when tab title is ambiguous - #65736
Conversation
…es with the same name
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Thank you, a few notes.
| // shown in the description rather than in the title. | ||
| .child( | ||
| Label::new(self.tab_content_text(params.detail.unwrap_or_default(), cx)) | ||
| Label::new(self.tab_content_text(0, cx)) |
There was a problem hiding this comment.
Editor::tab_content_text(0) can return a full path for single-file worktrees with an empty relative path (items.rs:2336–2343).
For an external /tmp/out/README.md, the new code supplies Preview /tmp/out/README.md as the primary label and /tmp/out again as the subtitle, without any collision.
Keep the path-aware key for disambiguation, but build the displayed label from editor.title(cx), matching the existing editor rendering.
There was a problem hiding this comment.
Good catch, thanks! Fixed, the title now uses editor.title(cx). MB I didn't consider external files.
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Great, thank you for the context on the new API.
One more findings meanwhile.
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Nice, thank you for all the fixes!
|
Thanks for the thorough review, learned a lot from it! |
Summary
Closes #65528
Previewing two files with the same name (e.g.
docs/README.mdandguide/README.md) showed two tabs both titledPreview README.md, with no way to tell them apart.Panes disambiguate tabs by calling
Item::tab_content_textwith an increasingdetailuntil the titles differ, then pass the chosen level totab_content.MarkdownPreviewView::tab_content_textignoreddetail, so the pane never got past level 0.tab_content_textnow asks the source editor for its title at the requesteddetailand prefixesPreview. Without a name clash it's unchanged (Preview README.md).tab_contentshows the parent directories after the title as a small muted label, like editor tabs. For that, the description logic inEditor::tab_contentmoved into a new publicEditor::tab_description, which both use, so editor tabs render exactly as before.truncate_title_middle), the preview row now shrinks and truncates the same way editor entries do.The preview still doesn't report a project path, so navigation history and reopening closed tabs are unaffected.
Testing
preview_tabs_for_files_with_the_same_name_show_their_directory, which previewsdocs/README.mdandguide/README.mdin one pane, runs the pane's disambiguation (workspace::tab_details) and checks the titles arePreview docs/README.mdandPreview guide/README.md(usingpath!so it works on Windows). It fails without the fix.README.mdfrom different directories showdocs/zedafter the title, matching the editor tabs; the tab switcher entries truncate like editor entries.Self-review
Release Notes: