Skip to content

Fix autosave on focus change error when switching git diff via command palette - #53920

Closed
OmChillure wants to merge 2 commits into
zed-industries:mainfrom
OmChillure:fix-autosave-on-focus-change-error-when-switching-git-diff
Closed

Fix autosave on focus change error when switching git diff via command palette#53920
OmChillure wants to merge 2 commits into
zed-industries:mainfrom
OmChillure:fix-autosave-on-focus-change-error-when-switching-git-diff

Conversation

@OmChillure

@OmChillure OmChillure commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary of whats fixed:

  • Fixed the autosave regression where focus change to the command palette could trigger autosave at the wrong time in Vim/Helix workflows.
  • The behavior is now: defer autosave while command palette is active, then decide on dismiss:
  • Skip autosave if focus returns to the same item.
  • Run autosave if focus moved elsewhere.

Files changed:

  • Added deferred autosave queueing when focus leaves an item to command palette in crates/workspace/src/item.rs.
  • Added a modal dismissed event so workspace can react after modal close in crates/workspace/src/modal_layer.rs.
  • Wired workspace to process deferred autosaves on modal dismiss and added handling logic in crates/workspace/src/workspace.rs.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #53863

Video

Screencast.from.2026-04-14.22-57-12.webm

Release Notes:

  • Fixed autosave-on-focus-change behavior around command palette dismissal in Vim/Helix mode by covering deferred autosave semantics (skip when focus returns to same item, save when focus moves elsewhere).

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 14, 2026
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested a review from a team April 14, 2026 17:52
@zed-community-bot zed-community-bot Bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Apr 14, 2026
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested review from benbrandt and osyvokon and removed request for a team April 14, 2026 17:52
@benbrandt
benbrandt requested review from a team, as-cii and cole-miller and removed request for a team, benbrandt and osyvokon April 15, 2026 09:44
@benbrandt benbrandt assigned cole-miller and unassigned benbrandt Apr 15, 2026
@ConradIrwin

Copy link
Copy Markdown
Member

Thanks for this!

I'm going to try and attack the problem from a more holistic angle (seems like #45166 introduced a number of issues; and #51949 fixes some of them). It seems better to take the approach from this PR of deferring auto-saves and use it more consistently, avoiding the need for most of the logic in #51949.

ConradIrwin added a commit that referenced this pull request Apr 22, 2026
Self-Review Checklist:

Closes #53863

Updates #53920
Updates #51949
Updates #45166

Release Notes:

- Updated auto_save_on_focus_change to handle modals better.
kathbigra pushed a commit to kathbigra/zed that referenced this pull request May 10, 2026
Self-Review Checklist:

Closes zed-industries#53863

Updates zed-industries#53920
Updates zed-industries#51949
Updates zed-industries#45166

Release Notes:

- Updated auto_save_on_focus_change to handle modals better.
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Self-Review Checklist:

Closes zed-industries#53863

Updates zed-industries#53920
Updates zed-industries#51949
Updates zed-industries#45166

Release Notes:

- Updated auto_save_on_focus_change to handle modals better.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autosave on focus change doesn't trigger when switching to git diff via command palette

5 participants