zed
zed copied to clipboard
Autosave when focusing other panels (terminal, project, etc)
Check for existing issues
- [X] Completed
Describe the feature
Add an option to autosave when a non-editor panel is focused, in addition to on_window_change. This is similar to how IntelliJ Idea operates by default.
Motivation
We currently have two options for autosave. There a few drawbacks I see to both of these
on_window_change- This can be frustrating with an integrated terminal - you make changes in the editor, drop down to the terminal and try running those changes, and they haven't been saved. You accidentally ran old code, which can be confusing to diagnose
- This failure to react to changes may also apply to other panels, especially future "git" panels, "run/debug" panels, etc.
on_focus_change- It's very common to have multi-file edits. Saving on focus change can lead to premature saves, where one file is saved while the other is being edited, leaving the project in a broken state.
- This is mostly an issue if you have an automatic build process on file save. This is common with webdev, where you "watch" changes to files to recompile and serve them.
- The problem is exacerbated with exceptionally slow builds. I've worked in Angular projects where a rebuild takes upwards of a minute. Triggering a rebuild every time I focused another file would be untenable
If applicable, add mockups / screenshots to help present your vision of the feature
No response
So you want something like "autosave": "on_focus_change_panel" and "autosave": "on_focus_change_buffer"?
By the way, in my zed there is a ~2s delay until autosave kicks in after I focus out with "autosave": "on_focus_change". A little annoying. Does this happen to you too?
Haven’t noticed the delay myself, but I’m not using zed as my daily driver yet. Not sure of the best name. We could even call it on_window_change and have certain panels (terminal, git, etc) require the buffer be saved and be treated like a new window
We currently have two options for autosave
Wait a second, WE ALREADY have such a feature in Zed? I wasn’t able to find that using fuzzy search in settings json
I believe autosave in JetBrains or Vs code is good example how to implement it.
"autosave": "on_focus_change" seems to do the job and the feature seems to be documented well here: https://zed.dev/docs/configuring-zed?highlight=Formatter#autosave @vultix @JosephTLyons I guess the issue could be closed?