Skip to content

Keep undo history even when file changes outside Code #2908

Closed

Description

When a file is being modified in Code, then an external process modifies something in the file, for example a code formatter, the modification is loaded instantly in Code, but all the history is lost.
Expected behavior would be to have the external modification, as one entry in the history.

Steps to reproduce:

1 - Start a new file in VS Code and start typing in the file, then save the file. Keep the file and VS Code open.
2 - Open the same file in another editor. Modify some thing and save.
3 - Go back to VS Code , there is not 'Undo' available.

Activity

  1. added
    feature-request
    on Feb 10, 2016
  2. alexdima commented on Feb 10, 2016

    @alexdima
    Member

    Indeed, the current handling of a file change on disk is to drop the old buffer and allocate everything fresh. I'm wondering what other editors do...

    fyi Benjamin Pasero (@bpasero)

  3. majidfn commented on Feb 11, 2016

    @majidfn
    Author

    Sublime considers the external modification as an entry in the history. So if you do one undo all the external modifications would be reverted, and if you keep undoing, you would get back to history of modifications you did in the same window.

    The problem with dropping the buffer is when you have an external process to monitor the files and for example format it. (i.e. go fmt or js-beautify). So this would result in to lose all the history in the editor.

  4. changed the title [-]External file modification loses the history[/-] [+]Keep undo history even when file changes outside Code[/+] on Feb 29, 2016
  5. bpasero commented on Feb 29, 2016

    @bpasero
    Contributor

    Would indeed be very nice to preserve the undo history even for changes outside Code.

  6. senocular commented on Oct 12, 2016

    @senocular

    This has saved me in Sublime before; I'd really like to see it in code.

    Scenario: Working with multiple repos in multiple terminals, VS Code used to edit files in one (still using the terminal for git operations). In a terminal for another repo I want to blow away any unstaged changes so I throw a git checkout -- . at it. Surprise! That was the terminal for files open Code, not the other one I really wanted. How do I get those changes back? Ideally I'd just go into each open buffer and undo to get those edits back.

  7. aga5tya commented on Oct 18, 2016

    @aga5tya

    This is the only thing that keeps me going back to atom or sublime. Would love to see this feature implemented. Is it in the pipeline or planned..?

  8. novascreen commented on Oct 24, 2016

    @novascreen

    Agree, that feature in Sublime has been a life saver many times.

  9. jamietre commented on Dec 7, 2016

    @jamietre

    Just blew away two hours of work by typing git checkout -- * in the wrong console. Sad to find this as an open feature request instead of a lifeline! (And frankly kind of surprised that by now, git doesn't just cache things it overwrites in some non-persistent space so you have a quick undo recourse, seems like it would be a pretty simple idiot saver)

  10. 18 remaining items

  11. langdonx commented on Aug 9, 2017

    @langdonx
  12. marcoscaceres commented on Aug 18, 2017

    @marcoscaceres

    I'm also affected by this. Means I still need to use sublime for certain projects.

  13. hanzoz commented on Aug 26, 2017

    @hanzoz

    yeah, this will be good. the undo function of sublime it's really a life saver

  14. pelotom commented on Aug 28, 2017

    @pelotom

    +1

  15. alexdima commented on Aug 28, 2017

    @alexdima
    Member

    Thanks to Ryan Stringham (@stringham) , if all goes well with testing, this will make it into our August release.

  16. akanshgulati commented on Nov 15, 2017

    @akanshgulati

    When we can expect this to be live as today I faced the same issue while trying tasks in vscode. I created a wrong task and boom, my file was changes and now I can not undo it at all.

  17. rhymes commented on Nov 16, 2017

    @rhymes

    Akansh Gulati (@akanshgulati) AFAIK this has been live since September. I'm on version 1.18.0 and it works

  18. akanshgulati commented on Nov 16, 2017

    @akanshgulati

    rhymes (@rhymes) I tried using cmd + z to undo it but could not revert to that previous state. Are you saying that above problem which I mentioned is solved through this issue or I am referring different problem altogether?

  19. rhymes commented on Nov 16, 2017

    @rhymes

    Akansh Gulati (@akanshgulati) I don't know if it's the same problem.

    Try: open a text file with vscode, write something in it, open the same file with another editor, change the content, go back to vscode and you'll see the new content, do cmd - z and you should see the original content.

    It also works with "git checkout -- file.txt" in case you're working inside a git repository.

  20. locked and limited conversation to collaborators on Nov 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestfile-exploreron-testplan

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions