Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Make possible to undo (redo) changes in code after VS Code's been restarted #43555

Open
user3323 opened this issue Feb 13, 2018 · 21 comments
Labels
editor-core Editor basic functionality feature-request Request for new features or functionality undo-redo Issues around undo/redo
Milestone

Comments

@user3323
Copy link

  • 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?

@vscodebot vscodebot bot added editor editor-core Editor basic functionality labels Feb 13, 2018
@alexdima alexdima added feature-request Request for new features or functionality and removed editor labels Feb 13, 2018
@alexdima alexdima added this to the Backlog milestone Feb 13, 2018
@alexdima alexdima removed their assignment Feb 13, 2018
@cmmp
Copy link

cmmp commented May 11, 2018

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.

@airato
Copy link

airato commented Oct 19, 2018

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.

@spacepluk
Copy link

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.

@Dominik-K
Copy link

Undo/redo after file or tab closing, not VSCode reload or restart, is discussed in #7169 (@Ahmed-Hussein-Karam, @airato).

@zwhitchcox
Copy link

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.

@ivolucien
Copy link

ivolucien commented Jun 18, 2019

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.

@vpalos
Copy link

vpalos commented Jun 26, 2019

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!

@mh-firouzjah
Copy link

And any new news ?
Is that bug still there?

@desmap
Copy link

desmap commented Jul 18, 2019

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.

@mkanet
Copy link

mkanet commented Aug 4, 2019

Is there an extension that will do this? I'm not even sure what to search for.

@rebornix rebornix removed their assignment Aug 5, 2019
@dannyfranca
Copy link

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

@dannyfranca
Copy link

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.

@haifengkao
Copy link

haifengkao commented Oct 7, 2019

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

@rahmanunver
Copy link

And that hero never came.

@alexdima alexdima added the undo-redo Issues around undo/redo label Feb 26, 2020
@phil294
Copy link

phil294 commented Apr 11, 2020

The undo history is now preserved when you close a tab. Not the case for restarting vscode entirely though.

@nodehead
Copy link

nodehead commented Apr 12, 2020

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.

@phil294
Copy link

phil294 commented Apr 12, 2020

@nodehead There is a seperate issue for the new undo mechanic: #7169, while this one is about preserving the changes after IDE restart.

Making the new mechanic configurable is also shortly discussed in that issue, and #94778 is the continuation. You'll probably want to participante in there.

@mstgnz
Copy link

mstgnz commented Apr 26, 2020

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?

@phptek
Copy link

phptek commented May 13, 2020

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 :-)

@boltex
Copy link

boltex commented Aug 13, 2020

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!

@ivolucien
Copy link

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 touched the file the undo is reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-core Editor basic functionality feature-request Request for new features or functionality undo-redo Issues around undo/redo
Projects
None yet
Development

No branches or pull requests