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.

tab_switcher: Show full file names without truncation (#58483)

saberoueslatiea7b4c75ee7d
diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs
index 884f5a83251..7fe643ab681 100644
--- a/crates/editor/src/items.rs
+++ b/crates/editor/src/items.rs
@@ -767,7 +767,10 @@ impl Item for Editor {
return None;
}
- Some(util::truncate_and_trailoff(description, MAX_TAB_TITLE_LEN))
+ Some(util::truncate_and_trailoff(
+ description,
+ params.max_title_len.unwrap_or(MAX_TAB_TITLE_LEN),
+ ))
});
// Whether the file was saved in the past but is now deleted.
@@ -783,7 +786,7 @@ impl Item for Editor {
.child(
Label::new(util::truncate_and_trailoff(
&self.title(cx),
- MAX_TAB_TITLE_LEN,
+ params.max_title_len.unwrap_or(MAX_TAB_TITLE_LEN),
))
.color(label_color)
.when(params.preview, |this| this.italic())
diff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rs
index 1f09a55aecd..9f9f706780b 100644
--- a/crates/tab_switcher/src/tab_switcher.rs
+++ b/crates/tab_switcher/src/tab_switcher.rs
@@ -830,6 +830,7 @@ impl PickerDelegate for TabSwitcherDelegate {
selected: true,
preview: tab_match.preview,
deemphasized: false,
+ max_title_len: Some(usize::MAX),
};
let label = tab_match.item.tab_content(params, window, cx);
diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs
index 7b247a073c1..c2fbfc94463 100644
--- a/crates/workspace/src/item.rs
+++ b/crates/workspace/src/item.rs
@@ -133,6 +133,8 @@ pub struct TabContentParams {
pub preview: bool,
/// Tab content should be deemphasized when active pane does not have focus.
pub deemphasized: bool,
+ /// Maximum character length for the title. None = use the item's own default (typically MAX_TAB_TITLE_LEN).
+ pub max_title_len: Option<usize>,
}
impl TabContentParams {
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
index 3a44e051167..02d0a301353 100644
--- a/crates/workspace/src/pane.rs
+++ b/crates/workspace/src/pane.rs
@@ -2794,6 +2794,7 @@ impl Pane {
selected: is_active,
preview: is_preview,
deemphasized: !self.has_focus(window, cx),
+ max_title_len: None,
},
window,
cx,
@@ -4930,6 +4931,7 @@ impl Render for DraggedTab {
selected: false,
preview: false,
deemphasized: false,
+ max_title_len: None,
},
window,
cx,