Feature Request - Make possible to undo (redo) changes in code after VS Code's been restarted
Opened this issue ยท 21 comments
- VSCode Version: 1.21.0-ins
- OS Version: win7x64
It would be great to undo (Ctrl+Z) and redo (Ctrl+Y) changes in the code we've done, after VS Code's been closed and restarted.
Is it hard to implement?
I think it would be a very useful feature. I also don't think that the subsequent drawback as mentioned is really an issue, since if there is infinite ctrl+z there should be infinite redo (CTRL+Y) as well, allowing you to return to whatever state the file was opened.
In my opinion closing/opening a tab in vs-code is not perceived as closing/opening a file, it's just a tab which can be opened and closed for the same file many times. and the fact that closing a tab has side effects is not clear, and users have to learn that on their own after they lose their changes few times.
And there still will be Ctrl+Shift+Z to go back and forth.
this feature is needed since it's counterintuitive that Ctrl+Z history disappears when you for example Reload window, or even close a tab and open it back. I would even qualify current state as a bug, not as a feature.
This is one of the things that are keeping me in vim. I don't think the subsequent drawback mentioned above is a problem especially when you are using git or other vcs.
Undo/redo after file or tab closing, not VSCode reload or restart, is discussed in #7169 (@Ahmed-Hussein-Karam, @airato).
I recently switched from vim to vscode, and this is the only extremely useful feature that is not included in VS Code.
I don't know if @Ahmed-Hussein-Karam has ever actually had persistent undo, but it is absolutely amazing.
I'm not going to be able to do it justice if I try to explain all the benefits verbally, but just trust me, it's earth-shattering.
Full undo / redo for both tab and vscode restarts would be amazing!
IMO it should be off by default but supported by turning on a config flag.
Before VSCode, I used Atom.io for a short while. I absolutely loved moving to VSC, but the only thing I truly missed was this: https://atom.io/packages/persistent-undo.
This feature would be just amazing!
And any new news ?
Is that bug still there?
you will go beyond that state,
That's not a problem because in vim you see a visual indicator, basically [+]
is removed, when you crossed that state.
I work with this setup in vim for ages and never had any problems. @octref, would be nice to see an update on this or somebody being assigned.
Is there an extension that will do this? I'm not even sure what to search for.
Is there an extension that will do this? I'm not even sure what to search for.
I don't think so, it's a core feature
At least when we close a tab, the history should remain, similar to WebStorm. Not necessarily after reloading VSCode itself, but it's a great feature.
I think we can make persistent undo by modifying local-history and remap the undo and redo key.
We only need a brave hero to implement it
And that hero never came.
The undo history is now preserved when you close a tab. Not the case for restarting vscode entirely though.
Is anyone aware of a way / is there a way to disable the new undo stack behavior? A search of settings doesn't show anything obvious, and the update note doesn't list any settings.
While I certainly see why this would be useful, and desirable, it is also a major change in default behavior if there is no opt-out setting. Perhaps it's just me, but I frequently open a file, trying something, then discarding it by holding down CTRL/CMD + Z and expecting that to return the file state to where it was on open.
I accidentally undid committed changes today with the new behavior -- not the end of the world, and easily remedied once I realized what had happened, but slightly annoying.
Edit: to be clear, not complaining about the feature in any way, just wondering if there is a way to return to the old behavior that I haven't found.
friend I just want to undo the changes made with the file open. why did you request such a thing? he says back all the time. I want to come back to the last registered yield. going back to the last commit. Doesn't it have a setting?
Is it just me that finds "persistent undo" the weirdest thing ever? It's like expecting the bottom of the stairs to arrive in a block of flats on ten floors, but going down past that to the 20th and beyond!
As @nodehead said pretty well - this should be configurable. Several times I've undone committed changes which is just plain weird! I used Netbeans since forever (and heaps of standard text editors) the default is "sane": If you've closed a tab or a window, you closed the file. EOS.
If you want a config setting to enable that (and maybe I'm just too old, but I ask "why would you"?) then fine, but don't make it a default and/or provide a setting to control this so VSC behaves like a "standard" editor.
Thx team :-)
Re-pasting my question here because it is somewhat related. I need to prevent undos from persisting!
My extension (https://github.com/boltex/leointeg) uses file system api to implement custom 'editors' for my needs as indicated in the docunmentation here https://code.visualstudio.com/api/extension-guides/virtual-documents#file-system-api .
I need to be able to 'block' or 'clear' undos when closing or switching from one of them to another.
It used to be that doing vscode.WorkspaceEdit "rename" operation would 'clear'/'block' all undos for the newly named document to traverse across the point where the document was renamed, but lately the newer versions of vscode tries to open a document with the old name when pressing ctrl+Z on a newly renamed document (in a custom filesystem)... Is there a way to disable that? Or a way to clear the undo stack for a given document URL? or for a filesystem scheme only in particular?
Thanks to anyone who can clarify 'undo stack' persistence behavior!
Is it just me that finds "persistent undo" the weirdest thing ever? It's like expecting the bottom of the stairs to arrive in a block of flats on ten floors, but going down past that to the 20th and beyond!
@phptek - FWIW persistent undo is "new" on the scale of it, at least 10 years old for vim. My comment in my above ticket, June 2019, suggests that persistent undo be off by default since it's a big change in behavior. vim's version is smart in that any non-vim change to the file, even metadata IIRC, resets the undo stack. So if you've pulled a new branch or even touch
ed the file the undo is reset.