zed icon indicating copy to clipboard operation
zed copied to clipboard

Remember unsaved changes

Open probablykasper opened this issue 2 years ago • 6 comments

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

probablykasper avatar Jun 18 '23 22:06 probablykasper

Even though this issue: https://github.com/zed-industries/zed/issues/4985 is newer, it has more upvotes, so perhaps close this as duplicate?

porsager avatar Feb 05 '24 07:02 porsager

This issue is broader in scope than that one

probablykasper avatar Feb 05 '24 08:02 probablykasper

Oh, don't know what I'm overlooking, how are they different?

porsager avatar Feb 05 '24 08:02 porsager

This one is for any unsaved changes, not just untitled files

probablykasper avatar Feb 05 '24 08:02 probablykasper

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!

porsager avatar Feb 05 '24 08:02 porsager

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.

muja avatar May 08 '24 04:05 muja

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

LoganDark avatar May 22 '24 18:05 LoganDark

wow! the long awaited feature has been merged in #13546, any idea when it will be released?

jcalvopinam avatar Jul 20 '24 16:07 jcalvopinam

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:

  1. If the file changes in the meantime via another source, should the user be notified?
  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.

The untitled files has no drawbacks though.

muja avatar Jul 21 '24 14:07 muja

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.


  1. 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.

mrnugget avatar Jul 22 '24 07:07 mrnugget

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

muja avatar Jul 22 '24 15:07 muja

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?

mrnugget avatar Jul 22 '24 17:07 mrnugget

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

muja avatar Jul 22 '24 18:07 muja

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.

mrnugget avatar Jul 23 '24 09:07 mrnugget

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?

porsager avatar Jul 23 '24 09:07 porsager

Yep, exactly. You can see that at the end of the demo video in here: https://github.com/zed-industries/zed/pull/13546

mrnugget avatar Jul 23 '24 17:07 mrnugget

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!

JosephTLyons avatar Jul 24 '24 16:07 JosephTLyons