mirror of
https://github.com/zed-industries/zed.git
synced 2026-10-21 05:31:11 +00:00
## Summary Closes #65528 Previewing two files with the same name (e.g. `docs/README.md` and `guide/README.md`) showed two tabs both titled `Preview README.md`, with no way to tell them apart. Panes disambiguate tabs by calling `Item::tab_content_text` with an increasing `detail` until the titles differ, then pass the chosen level to `tab_content`. `MarkdownPreviewView::tab_content_text` ignored `detail`, so the pane never got past level 0. - `tab_content_text` now asks the source editor for its title at the requested `detail` and prefixes `Preview `. Without a name clash it's unchanged (`Preview README.md`). - `tab_content` shows the parent directories after the title as a small muted label, like editor tabs. For that, the description logic in `Editor::tab_content` moved into a new public `Editor::tab_description`, which both use, so editor tabs render exactly as before. - In the tab switcher (`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. <img width="1059" height="45" alt="image" src="https://github.com/user-attachments/assets/5f54fee6-1889-4942-a713-b11c5da88b46" /> ## Testing - Added `preview_tabs_for_files_with_the_same_name_show_their_directory`, which previews `docs/README.md` and `guide/README.md` in one pane, runs the pane's disambiguation (`workspace::tab_details`) and checks the titles are `Preview docs/README.md` and `Preview guide/README.md` (using `path!` so it works on Windows). It fails without the fix. - Manually tested on Linux: two previews of `README.md` from different directories show `docs` / `zed` after the title, matching the editor tabs; the tab switcher entries truncate like editor entries. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Fixed Markdown preview tabs for files with the same name not showing their directory. |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| LICENSE-GPL | ||