Keep undo stack between file close and reopen
joaomoreno opened this issue Β· 28 comments
- Make a change in a file
- Close it Ctrl W
- Open it again Ctrl Shift T
Undo stack is lost π’
Fixed recently.
Updated original steps.
We dispose the editor when you close it and this means we get rid of the undo stack. This needs support from the editor to store the undo stack with the editor and resource (maybe similar to storing the view state)?
@alexandrudima moving to you.
We have the content hash now, but not a serializable undo/redo stack
IMHO this should go on the plan rather than me doing it under the radar. @joaomoreno you can lobby for it
This bug is back again. I'm using Version 1.17.2. This one bug makes VS Code almost unusable for me, since it's such a common part of my workflow.
Also broken in Insiders: Version 1.18.0-insider.
I confirm broken in version 1.18.1, also on version 1.19.0-insider
This is still an issue... cmd+w
by accident, cmd+shift+t
a split second later and all my edit history is gone. Infuriating. This has probably cost me hours of dev time over the last month...
There are bugs like this one that leave vs code feeling quite unfinished as an overall product.
Was this ever possible at all? I am seeing conflicting statements here.
Is this a bug or a feature request?
Also see #47874.
is there any update to this issue?
Confirmed this is still not working. I prefer VSCode to Webstorm in every aspect except for this. Webstorm will keep a long running local revision history, and VSCode can't even keep it for 5 seconds after closing a file.
even vim
supports this... you can close a buffer and re-open it and maintain your undo stack, or even quit vim entirely and re-open it in a different terminal and keep your undo history.
set undodir=~/.vim/tmp/backup/
set undofile
I am also missing this feature.
The undo history is also lost when renaming a file, even if it's open.
Oh God, please make this optional, default "on" if you want, but put an option that I can turn off. Some people like me, like to ditch the undo/redo history this way! You know, open the file clean, no undo history, etc. Existence of this feature is the main reason I hate Web Storm, and prefer VS Code, and now you are making this default here also! OMG
About the XKCD analogy... The funny thing is that it's more like the other way around. Something like, you have just fixed a bug for people with a non-working "Control + w" on their keyboard, with a permanent, non opt-out binding of the "Spacebar" anywhere in the app, interpreting its single press with a rapidly heating the CPU, making your OS freeze, thus closing the currently opened files with a hardware reboot.
Oh God, please make this optional, default "on" if you want, but put an option that I can turn off. Some people like me, like to ditch the undo/redo history this way! You know, open the file clean, no undo history, etc. Existence of this feature is the main reason I hate Web Storm, and prefer VS Code, and now you are making this default here also! OMG
I view it as, I like to keep a clean list of open editors, rather than a clean undo history. The open editors (or tabs if you configure that way) are visual. The undo history is not.
I'll also note that unlike webstorm, VSCode is open source and accepts community contributions so if a configuration option isn't present you can implement one.
Oh God, please make this optional, default "on" if you want, but put an option that I can turn off. Some people like me, like to ditch the undo/redo history this way! You know, open the file clean, no undo history, etc. Existence of this feature is the main reason I hate Web Storm, and prefer VS Code, and now you are making this default here also! OMG
Not trying to invalidate your point, but could you please explain what you need to ditch the undo history for? Is it so that you can spam "undo" without worrying about going back further than desired?
It seems that now that this issue got closed, your best bet is probably to open up a new one. Either way you have a point, since making new features configurable is rarely a bad idea
Reading the comments of past years I see how useful this new feature is for some. I always saw the bug more like a feature over WebStorm though hehe.
even
vim
supports this... you can close a buffer and re-open it and maintain your undo stack, or even quit vim entirely and re-open it in a different terminal and keep your undo history.set undodir=~/.vim/tmp/backup/ set undofile
And even vim
supports disabling persistent undo :)
Not trying to invalidate your point, but could you please explain what you need to ditch the undo history for? Is it so that you can spam "undo" without worrying about going back further than desired?
It's my own specific case yes, to be able to spam "undo" without worries. When I close a tab in VSCode I mean to say "I'm closing this file" not "I'm hiding this file", hitting β+Z
and seeing the file contents change feels like I just hid it from the view (like @charrondev mentioned). When I have multiple VSCode windows open (and several tabs on each), hitting β+Z
on a file without seeing changes gives me the feel that the file (of all open files/tabs) hasn't been edited since open and it's clean.
Not a dealbreaker for me tbh, but I agree with @phil294, it would be nice that these kind of features were configurable.
Anyways, somebody opened the issue #94778 requesting a configurable persistent undo.
I also think it should be optional. In my case, if I close a file is because I already finished modifying it, so I don't need the history anymore. The next time I open that file I expect an empty undo/redo list, and now If change something and then I press ctrl + z by twice I can delete something or add something I wrote or deleted previously, so I my case now I need to be very careful while pressing ctrl + z, I need to check that several times to verify I didn't break anything. Also you need to think that for most of the cases people open and close their files several times while coding and this behavior could affect them as I explained, and only a very small percentage of cases would be the 'accidents' that they said. VSCode is a code editor, not a version tracker.
Coming from vim, I am astonished that no one is missing this feature?! Persistent undo stacks are great for rapid prototyping - kinda like a "git liteβ’οΈ". Sad to see this issue closed. π’π