Skip to content

Don't trigger autosave on focus change in modals - #45166

Merged
probably-neb merged 1 commit into
mainfrom
dont-trigger-autosave-on-focus-loss-in-modals
Dec 17, 2025
Merged

Don't trigger autosave on focus change in modals#45166
probably-neb merged 1 commit into
mainfrom
dont-trigger-autosave-on-focus-loss-in-modals

Conversation

@probably-neb

Copy link
Copy Markdown
Collaborator

Closes #28732

Release Notes:

  • Opening the command palette or other modals no longer triggers auto-save with the { "autosave": "on_focus_change" } setting. This reduces the chance of unwanted format changes when executing actions, and fixes a race condition with :w in Vim mode

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Dec 17, 2025
@probably-neb
probably-neb merged commit 25e1e2e into main Dec 17, 2025
24 checks passed
@probably-neb
probably-neb deleted the dont-trigger-autosave-on-focus-loss-in-modals branch December 17, 2025 22:42
rtfeldman pushed a commit that referenced this pull request Jan 5, 2026
Closes #28732

Release Notes:

- Opening the command palette or other modals no longer triggers
auto-save with the `{ "autosave": "on_focus_change" }` setting. This
reduces the chance of unwanted format changes when executing actions,
and fixes a race condition with `:w` in Vim mode
maxdeviant added a commit that referenced this pull request Mar 19, 2026
…x command palette (#51949)

This PR adjusts the logic that was added in #45166 to just apply to the
specific case of interacting with the command palette in Vim and Helix
modes (hereafter referred to collectively as "Vim mode").

In that PR, we would suppress the auto-save on focus change for _any_
modal in the workspace, regardless of whether we were actually in Vim
mode or not. This would cause issues where moving between files some
other way—such as the tab switcher or the file finder—would cause the
buffers to never be saved.

We now only suppress the auto-save on focus loss behavior when in Vim
mode and the active modal is the command palette. In all other cases, we
save the file.

Closes #47968.

Supersedes #51801 and
#51802.

Note: the way we are identifying the active modal as the command palette
isn't the best, but @bennetbo and I didn't have any other cleaner
solutions. It's a bit tricky, as the logic lives in the `workspace`,
which isn't able to know about the `CommandPalette` due to
`command_palette` depending on `workspace`. There may be some other way
we could achieve this with more indirection, but it's unclear whether it
would be worth it at this time.

Release Notes:

- Changed `{ "autosave": "on_focus_change" }` to now always save on
focus loss, except for when activating the command palette when in
Vim/Helix mode.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
…x command palette (zed-industries#51949)

This PR adjusts the logic that was added in zed-industries#45166 to just apply to the
specific case of interacting with the command palette in Vim and Helix
modes (hereafter referred to collectively as "Vim mode").

In that PR, we would suppress the auto-save on focus change for _any_
modal in the workspace, regardless of whether we were actually in Vim
mode or not. This would cause issues where moving between files some
other way—such as the tab switcher or the file finder—would cause the
buffers to never be saved.

We now only suppress the auto-save on focus loss behavior when in Vim
mode and the active modal is the command palette. In all other cases, we
save the file.

Closes zed-industries#47968.

Supersedes zed-industries#51801 and
zed-industries#51802.

Note: the way we are identifying the active modal as the command palette
isn't the best, but @bennetbo and I didn't have any other cleaner
solutions. It's a bit tricky, as the logic lives in the `workspace`,
which isn't able to know about the `CommandPalette` due to
`command_palette` depending on `workspace`. There may be some other way
we could achieve this with more indirection, but it's unclear whether it
would be worth it at this time.

Release Notes:

- Changed `{ "autosave": "on_focus_change" }` to now always save on
focus loss, except for when activating the command palette when in
Vim/Helix mode.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
…x command palette (zed-industries#51949)

This PR adjusts the logic that was added in zed-industries#45166 to just apply to the
specific case of interacting with the command palette in Vim and Helix
modes (hereafter referred to collectively as "Vim mode").

In that PR, we would suppress the auto-save on focus change for _any_
modal in the workspace, regardless of whether we were actually in Vim
mode or not. This would cause issues where moving between files some
other way—such as the tab switcher or the file finder—would cause the
buffers to never be saved.

We now only suppress the auto-save on focus loss behavior when in Vim
mode and the active modal is the command palette. In all other cases, we
save the file.

Closes zed-industries#47968.

Supersedes zed-industries#51801 and
zed-industries#51802.

Note: the way we are identifying the active modal as the command palette
isn't the best, but @bennetbo and I didn't have any other cleaner
solutions. It's a bit tricky, as the logic lives in the `workspace`,
which isn't able to know about the `CommandPalette` due to
`command_palette` depending on `workspace`. There may be some other way
we could achieve this with more indirection, but it's unclear whether it
would be worth it at this time.

Release Notes:

- Changed `{ "autosave": "on_focus_change" }` to now always save on
focus loss, except for when activating the command palette when in
Vim/Helix mode.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
…x command palette (zed-industries#51949)

This PR adjusts the logic that was added in zed-industries#45166 to just apply to the
specific case of interacting with the command palette in Vim and Helix
modes (hereafter referred to collectively as "Vim mode").

In that PR, we would suppress the auto-save on focus change for _any_
modal in the workspace, regardless of whether we were actually in Vim
mode or not. This would cause issues where moving between files some
other way—such as the tab switcher or the file finder—would cause the
buffers to never be saved.

We now only suppress the auto-save on focus loss behavior when in Vim
mode and the active modal is the command palette. In all other cases, we
save the file.

Closes zed-industries#47968.

Supersedes zed-industries#51801 and
zed-industries#51802.

Note: the way we are identifying the active modal as the command palette
isn't the best, but @bennetbo and I didn't have any other cleaner
solutions. It's a bit tricky, as the logic lives in the `workspace`,
which isn't able to know about the `CommandPalette` due to
`command_palette` depending on `workspace`. There may be some other way
we could achieve this with more indirection, but it's unclear whether it
would be worth it at this time.

Release Notes:

- Changed `{ "autosave": "on_focus_change" }` to now always save on
focus loss, except for when activating the command palette when in
Vim/Helix mode.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
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.
piper-of-dawn pushed a commit to piper-of-dawn/zed that referenced this pull request Apr 25, 2026
…x command palette (zed-industries#51949)

This PR adjusts the logic that was added in zed-industries#45166 to just apply to the
specific case of interacting with the command palette in Vim and Helix
modes (hereafter referred to collectively as "Vim mode").

In that PR, we would suppress the auto-save on focus change for _any_
modal in the workspace, regardless of whether we were actually in Vim
mode or not. This would cause issues where moving between files some
other way—such as the tab switcher or the file finder—would cause the
buffers to never be saved.

We now only suppress the auto-save on focus loss behavior when in Vim
mode and the active modal is the command palette. In all other cases, we
save the file.

Closes zed-industries#47968.

Supersedes zed-industries#51801 and
zed-industries#51802.

Note: the way we are identifying the active modal as the command palette
isn't the best, but @bennetbo and I didn't have any other cleaner
solutions. It's a bit tricky, as the logic lives in the `workspace`,
which isn't able to know about the `CommandPalette` due to
`command_palette` depending on `workspace`. There may be some other way
we could achieve this with more indirection, but it's unclear whether it
would be worth it at this time.

Release Notes:

- Changed `{ "autosave": "on_focus_change" }` to now always save on
focus loss, except for when activating the command palette when in
Vim/Helix mode.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
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
Closes zed-industries#28732

Release Notes:

- Opening the command palette or other modals no longer triggers
auto-save with the `{ "autosave": "on_focus_change" }` setting. This
reduces the chance of unwanted format changes when executing actions,
and fixes a race condition with `:w` in Vim mode
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…x command palette (zed-industries#51949)

This PR adjusts the logic that was added in zed-industries#45166 to just apply to the
specific case of interacting with the command palette in Vim and Helix
modes (hereafter referred to collectively as "Vim mode").

In that PR, we would suppress the auto-save on focus change for _any_
modal in the workspace, regardless of whether we were actually in Vim
mode or not. This would cause issues where moving between files some
other way—such as the tab switcher or the file finder—would cause the
buffers to never be saved.

We now only suppress the auto-save on focus loss behavior when in Vim
mode and the active modal is the command palette. In all other cases, we
save the file.

Closes zed-industries#47968.

Supersedes zed-industries#51801 and
zed-industries#51802.

Note: the way we are identifying the active modal as the command palette
isn't the best, but @bennetbo and I didn't have any other cleaner
solutions. It's a bit tricky, as the logic lives in the `workspace`,
which isn't able to know about the `CommandPalette` due to
`command_palette` depending on `workspace`. There may be some other way
we could achieve this with more indirection, but it's unclear whether it
would be worth it at this time.

Release Notes:

- Changed `{ "autosave": "on_focus_change" }` to now always save on
focus loss, except for when activating the command palette when in
Vim/Helix mode.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
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.
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Closes zed-industries#28732

Release Notes:

- Opening the command palette or other modals no longer triggers
auto-save with the `{ "autosave": "on_focus_change" }` setting. This
reduces the chance of unwanted format changes when executing actions,
and fixes a race condition with `:w` in Vim mode
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vim Mode :w interferes with format-on-save & autosave on focus loss

1 participant