Show workspace name before filename in window title (#20310)
when searching for the appropriate zed window, i scan a list of window titles. putting the workspace before the filename makes this list a lot easier to scan.  screenshot of [alt tab](https://alt-tab-macos.netlify.app/) in mac os demonstrating how putting the workspace first makes it easier to locate a project. Release Notes: - Improved window title by showing workspace name before filename
This commit is contained in:
parent
b0b29d91f9
commit
a409123342
1 changed files with 17 additions and 17 deletions
|
@ -3436,6 +3436,17 @@ impl Workspace {
|
||||||
let project = self.project().read(cx);
|
let project = self.project().read(cx);
|
||||||
let mut title = String::new();
|
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)) {
|
if let Some(path) = self.active_item(cx).and_then(|item| item.project_path(cx)) {
|
||||||
let filename = path
|
let filename = path
|
||||||
.path
|
.path
|
||||||
|
@ -3451,22 +3462,11 @@ impl Workspace {
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(filename) = filename {
|
if let Some(filename) = filename {
|
||||||
title.push_str(filename.as_ref());
|
|
||||||
title.push_str(" — ");
|
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() {
|
if project.is_via_collab() {
|
||||||
title.push_str(" ↙");
|
title.push_str(" ↙");
|
||||||
} else if project.is_shared() {
|
} else if project.is_shared() {
|
||||||
|
@ -6211,13 +6211,13 @@ mod tests {
|
||||||
.map(|e| e.id)
|
.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 pane
|
// Add a second item to a non-empty pane
|
||||||
workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
workspace.add_item_to_active_pane(Box::new(item2), None, true, 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| {
|
project.update(cx, |project, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
project.active_entry(),
|
project.active_entry(),
|
||||||
|
@ -6233,7 +6233,7 @@ mod tests {
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.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| {
|
project.update(cx, |project, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
project.active_entry(),
|
project.active_entry(),
|
||||||
|
@ -6250,11 +6250,11 @@ mod tests {
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.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 folder
|
// Remove a project folder
|
||||||
project.update(cx, |project, cx| project.remove_worktree(worktree_id, cx));
|
project.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]
|
#[gpui::test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue