Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Show better tab tooltip for multi buffers (#54060)

Kirill Bulatov053803099b56
diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs
index 87f97ad8e4e..5ad584f1a42 100644
--- a/crates/editor/src/items.rs
+++ b/crates/editor/src/items.rs
@@ -645,20 +645,25 @@ impl Item for Editor {
}
fn tab_tooltip_text(&self, cx: &App) -> Option<SharedString> {
- self.buffer()
- .read(cx)
+ let multi_buffer = self.buffer().read(cx);
+ if let Some(file) = multi_buffer
.as_singleton()
.and_then(|buffer| buffer.read(cx).file())
.and_then(|file| File::from_dyn(Some(file)))
- .map(|file| {
+ {
+ Some(
file.worktree
.read(cx)
.absolutize(&file.path)
.compact()
.to_string_lossy()
.into_owned()
- .into()
- })
+ .into(),
+ )
+ } else {
+ let title = multi_buffer.title(cx);
+ (!title.is_empty()).then(|| title.to_string().into())
+ }
}
fn telemetry_event_text(&self) -> Option<&'static str> {