Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Show workspace name before filename in window title (#20310)
Peter Schillinga409123342d6
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex a289e76134c..c289eaf12bc 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -3436,6 +3436,17 @@ impl Workspace {let project = self.project().read(cx);let mut title = String::new();+ for (i, name) in project.worktree_root_names(cx).enumerate() {+ if i > 0 {+ title.push_str(", ");+ }+ title.push_str(name);+ }++ if title.is_empty() {+ title = "empty project".to_string();+ }+if let Some(path) = self.active_item(cx).and_then(|item| item.project_path(cx)) {let filename = path.path@@ -3451,22 +3462,11 @@ impl Workspace {});if let Some(filename) = filename {- title.push_str(filename.as_ref());title.push_str(" — ");+ title.push_str(filename.as_ref());}}- for (i, name) in project.worktree_root_names(cx).enumerate() {- if i > 0 {- title.push_str(", ");- }- title.push_str(name);- }-- if title.is_empty() {- title = "empty project".to_string();- }-if project.is_via_collab() {title.push_str(" ↙");} else if project.is_shared() {@@ -6211,13 +6211,13 @@ mod tests {.map(|e| e.id));});- assert_eq!(cx.window_title().as_deref(), Some("one.txt — root1"));+ assert_eq!(cx.window_title().as_deref(), Some("root1 — one.txt"));// Add a second item to a non-empty paneworkspace.update(cx, |workspace, cx| {workspace.add_item_to_active_pane(Box::new(item2), None, true, cx)});- assert_eq!(cx.window_title().as_deref(), Some("two.txt — root1"));+ assert_eq!(cx.window_title().as_deref(), Some("root1 — two.txt"));project.update(cx, |project, cx| {assert_eq!(project.active_entry(),@@ -6233,7 +6233,7 @@ mod tests {}).await.unwrap();- assert_eq!(cx.window_title().as_deref(), Some("one.txt — root1"));+ assert_eq!(cx.window_title().as_deref(), Some("root1 — one.txt"));project.update(cx, |project, cx| {assert_eq!(project.active_entry(),@@ -6250,11 +6250,11 @@ mod tests {}).await.unwrap();- assert_eq!(cx.window_title().as_deref(), Some("one.txt — root1, root2"));+ assert_eq!(cx.window_title().as_deref(), Some("root1, root2 — one.txt"));// Remove a project folderproject.update(cx, |project, cx| project.remove_worktree(worktree_id, cx));- assert_eq!(cx.window_title().as_deref(), Some("one.txt — root2"));+ assert_eq!(cx.window_title().as_deref(), Some("root2 — one.txt"));}#[gpui::test]