Remember unsaved changes
Check for existing issues
- [X] Completed
Describe the feature
I'd like Zed to remember my unsaved changes for next time I open the app. This is useful to protect against crashes, but also when you just want to restart without saving.
When you close apps like VSCode, TextEdit and Pages, you're not asked at all if you want to save unsaved changes.
I often use unsaved files for todo lists and dealing with some temporary data files.
Related:
- https://github.com/zed-industries/zed/issues/4985
Even though this issue: https://github.com/zed-industries/zed/issues/4985 is newer, it has more upvotes, so perhaps close this as duplicate?
This issue is broader in scope than that one
Oh, don't know what I'm overlooking, how are they different?
This one is for any unsaved changes, not just untitled files
Oh wow.. You're right - My bad 🙈 I understood the other one as also being for unsaved changes! Then I think we should close that one, because having one without the other will simply lead to confusion!
Agree that it might lead to confusion, initially thought they are duplicates as well. However, saving changes universally seems a lot more complicated than starting out with untitled files. I believe the issues can co-exist.
If this is added, please add a feature to explicitly discard unsaved changes. I was nearly unable recently before finding this issue and finding out that thankfully I could restart Zed
wow! the long awaited feature has been merged in #13546, any idea when it will be released?
While I love that this has been added and was the major blocker for seriously considering zed, I just realized that the implementation of unsaved changes has two considerations:
- If the file changes in the meantime via another source, should the user be notified?
- Since no undo history is stored, will it be possible to revert changes? For example in VSCode, there is no way to restore a dirty file that was closed without saving which IMO is not a bug but a... bad feature.
The untitled files has no drawbacks though.
wow! the long awaited feature has been merged in #13546, any idea when it will be released?
It's going to be released in the Preview release on Wednesday, normal release next week — pending any bugs.
- If the file changes in the meantime via another source, should the user be notified?
Yeah, I don't know yet. What happens right now is that the "dirty"-content that Zed has saved will kept and the file still marked as dirty. But the user can throw that away by closing the tab and reopening it.
2. Since no undo history is stored, will it be possible to revert changes? For example in VSCode, there is no way to restore a dirty file that was closed without saving which IMO is not a bug but a... bad feature.
If you close a dirty file explicitly (i.e. closing the tab), you get the choice to Save/Discard/Cancel. If you Discard, there's no way to get back to the dirty contents.
I wouldn't call it a "bad feature" for that, because the user made an explicit choice to Discard the changes and, IMHO, at a certain point when thinking about different variations and attributes of the "restore unsaved buffers" feature, the question pops up of why not use the file system and actually save files?
I don't think this feature is supposed to re-implement version-controlled files. For that, there's the file system and version control.
If I close an unsaved file, a dialog will ask to either save, discard or cancel. If I close the entire application, the file will remain dirty and once reopened it will display the possibly stale buffer (ignoring intermittent changes), the only way out being to close+discard. "Bad feature" is a bit much but it's not ergonomic when the user forgets to save and becomes confused why there is a dirty flag with no easy way to figure it out, with the two easy ways to recover from this leading to progress loss (either by ctrl+s overwriting FS changes or by ctrl+w->discard)
For me it doesn't really matter since the "unsaved file" feature will definitely not be used (except accidentally), but was just meant as a heads up
If I close the entire application, the file will remain dirty and once reopened it will display the possibly stale buffer (ignoring intermittent changes), the only way out being to close+discard.
Is the issue the ignoring of the intermittent changes? Because otherwise it sounds like you just don't want to use the feature, no?
The feature is not really interesting for me because when I change a file in my editor and don't press Save, it's mostly because I forgot, so I'd prefer it if the application warned me when I try to close it.
Is the issue the ignoring of the intermittent changes?
The user opening Zed may be confused that their open files are dirty, unless very short time has passed, in the presence as well as absence of intermittent changes -- they differ only in their resulting consequences
so I'd prefer it if the application warned me when I try to close it.
It does — when you close the file/tab/buffer. Just not when you quit the application.
It does — when you close the file/tab/buffer. Just not when you quit the application.
But only because it will still be there when zed is opened again right?
Yep, exactly. You can see that at the end of the demo video in here: https://github.com/zed-industries/zed/pull/13546
The following PRs have added quite a bit to the workspace serialization story:
- https://github.com/zed-industries/zed/pull/13546
- https://github.com/zed-industries/zed/pull/14965
There are a few known missing bits here, but I think its best that we close this issue out, in favor of new issues that describe those missing bit, so that we can get a clear understanding of how important these bits are to you all, now that most of the functionality has landed. Here are the new issues (upvote via 👍):
- https://github.com/zed-industries/zed/issues/15098
- https://github.com/zed-industries/zed/issues/15097
Killer work @mrnugget!