markdown_preview: Show source path in tab tooltip (#64318)

# Objective

Fixes #64129.

## Solution

Reuse the source editor's tab tooltip for Markdown preview tabs.

## Showcase

<img width="1582" height="962" alt="Markdown preview tab showing its
source file path tooltip"
src="https://github.com/user-attachments/assets/cba7dcfc-f7e7-460c-aaff-ce588321d146"
/>

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed Markdown preview tabs not showing their source file path on
hover.
This commit is contained in:
Gautam Manchandani authored and GitHub committed 2026-09-16 18:28:12 +00:00
1 parent be1e2facfa
commit 4f10bb6fbc
1 file changed
+34 -1
@@ -1640,6 +1640,14 @@ impl Item for MarkdownPreviewView {
.unwrap_or_else(|| SharedString::from("Markdown Preview"))
}
fn tab_tooltip_text(&self, cx: &App) -> Option<SharedString> {
self.active_editor
.as_ref()?
.editor
.read(cx)
.tab_tooltip_text(cx)
}
fn telemetry_event_text(&self) -> Option<&'static str> {
Some("Markdown Preview Opened")
}
@@ -2214,7 +2222,7 @@ mod tests {
use util::paths::{PathStyle, PathWithPosition};
use util::rel_path::{RelPath, rel_path};
use util::test::TempTree;
use workspace::item::{ItemHandle, SerializableItem};
use workspace::item::{Item, ItemHandle, SerializableItem};
use workspace::path_link::{OpenTarget, OpenTargetFoundBy};
use workspace::{
AppState, ItemId, MultiWorkspace, Pane, SaveIntent, Workspace, WorkspaceId, open_paths,
@@ -2246,6 +2254,31 @@ mod tests {
);
}
#[gpui::test]
async fn preview_tab_tooltip_matches_source_file_path(cx: &mut TestAppContext) {
let (project, _, multi_workspace) = markdown_workspace(
cx,
json!({
"docs": {
"guide.md": "# Guide"
}
}),
false,
)
.await;
let source_item =
open_project_file(cx, &project, &multi_workspace, "docs/guide.md", None, true).await;
let source_editor = cx.update(|cx| source_item.act_as::<Editor>(cx).unwrap());
let preview = open_preview_for_active_editor(cx, &multi_workspace);
let source_tooltip = source_editor.read_with(cx, |editor, cx| editor.tab_tooltip_text(cx));
assert!(source_tooltip.is_some());
assert_eq!(
preview.read_with(cx, |preview, cx| preview.tab_tooltip_text(cx)),
source_tooltip
);
}
#[gpui::test]
fn resetting_persisted_font_size_preserves_unrelated_settings(cx: &mut App) {
let settings_store = settings::SettingsStore::test(cx);