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.

Fix removed workspace resurrecting via serialization race (#52035)

Richard Feldman4049a4c91408
diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rs
index c3ec2e1c61e..6e4b99ebbfe 100644
--- a/crates/workspace/src/multi_workspace.rs
+++ b/crates/workspace/src/multi_workspace.rs
@@ -649,6 +649,16 @@ impl MultiWorkspace {
self.active_workspace_index -= 1;
}
+ // Clear session_id and cancel any in-flight serialization on the
+ // removed workspace. Without this, a pending throttle timer from
+ // `serialize_workspace` could fire and write the old session_id
+ // back to the DB, resurrecting the workspace on next launch.
+ removed_workspace.update(cx, |workspace, _cx| {
+ workspace.session_id.take();
+ workspace._schedule_serialize_workspace.take();
+ workspace._serialize_workspace_task.take();
+ });
+
if let Some(workspace_id) = removed_workspace.read(cx).database_id() {
let db = crate::persistence::WorkspaceDb::global(cx);
self.pending_removal_tasks.retain(|task| !task.is_ready());