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.

recent_projects: Wait for save intent before removing project (#65683)

Matei Oprea97511be201f4
diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rs
index 09464958834..93c0e9abe9e 100644
--- a/crates/workspace/src/multi_workspace.rs
+++ b/crates/workspace/src/multi_workspace.rs
@@ -965,9 +965,6 @@ impl MultiWorkspace {
let task = self.remove(workspaces, RemovalIntent::CloseProject, window, cx);
- self.project_groups.retain(|group| group.key != *group_key);
- cx.emit(MultiWorkspaceEvent::ProjectGroupsChanged);
-
task
}
@@ -1820,6 +1817,18 @@ impl MultiWorkspace {
let mut removed_any = false;
let displayed_workspace = this.workspace().clone();
+ // wait for should_continue to be true before removing project groups
+ if intent == RemovalIntent::CloseProject {
+ let workspace_to_delete_keys = workspaces
+ .iter()
+ .map(|workspace| workspace.read(cx).project_group_key(cx))
+ .collect::<Vec<_>>();
+
+ this.project_groups
+ .retain(|group| !workspace_to_delete_keys.contains(&group.key));
+ cx.emit(MultiWorkspaceEvent::ProjectGroupsChanged);
+ }
+
for workspace in &workspaces {
if *workspace == displayed_workspace {
continue;