Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Don't trigger autosave on focus change in modals (#45166)
Ben Kunkle25e1e2ecdd13
diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rsindex 4bde632ce72..1570c125fa3 100644--- a/crates/workspace/src/item.rs+++ b/crates/workspace/src/item.rs@@ -886,8 +886,12 @@ impl<T: Item> ItemHandle for Entity<T> {// Only trigger autosave if focus has truly left the item.// If focus is still within the item's hierarchy (e.g., moved to a context menu),// don't trigger autosave to avoid unwanted formatting and cursor jumps.+ // Also skip autosave if focus moved to a modal (e.g., command palette),+ // since the user is still interacting with the workspace.let focus_handle = item.item_focus_handle(cx);- if !focus_handle.contains_focused(window, cx) {+ if !focus_handle.contains_focused(window, cx)+ && !workspace.has_active_modal(window, cx)+ {Pane::autosave_item(&item, workspace.project.clone(), window, cx).detach_and_log_err(cx);}