You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep undo history even when file changes outside Code #2908
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.
Reacted by Anders Stenberg, Trevor McCauley, Mahmoud Saada, James Treworgy, BrickerBrickerOneNine, Todd Jones, stef-levesque, Stephan Behnke, Andrew Harper, Evandro Myller and 41 more
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.
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.
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)
Thanks to Ryan Stringham (@stringham) , if all goes well with testing, this will make it into our August release.
Reacted by Josh Buchea, Tom Crockett, Caleb Tote, Majid Fatemian, Diogo Lemos, Leo Caseiro, Ruben Bridgewater, Cosmin Lupu, John Daily Jr. and Ingvar Stepanyan
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.
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?
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.
Activity
alexdima commentedon Feb 10, 2016
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)
majidfn commentedon Feb 11, 2016
Sublime considers the external modification as an entry in the history. So if you do one
undoall the external modifications would be reverted, and if you keepundoing, 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 fmtorjs-beautify). So this would result in to lose all the history in the editor.[-]External file modification loses the history[/-][+]Keep undo history even when file changes outside Code[/+]bpasero commentedon Feb 29, 2016
Would indeed be very nice to preserve the undo history even for changes outside Code.
senocular commentedon Oct 12, 2016
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.aga5tya commentedon Oct 18, 2016
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..?
novascreen commentedon Oct 24, 2016
Agree, that feature in Sublime has been a life saver many times.
jamietre commentedon Dec 7, 2016
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)18 remaining items
langdonx commentedon Aug 9, 2017
rhymes (@rhymes) https://twitter.com/slicknet/status/782274190451671040
marcoscaceres commentedon Aug 18, 2017
I'm also affected by this. Means I still need to use sublime for certain projects.
hanzoz commentedon Aug 26, 2017
yeah, this will be good. the undo function of sublime it's really a life saver
pelotom commentedon Aug 28, 2017
+1
alexdima commentedon Aug 28, 2017
Thanks to Ryan Stringham (@stringham) , if all goes well with testing, this will make it into our August release.
akanshgulati commentedon Nov 15, 2017
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.
rhymes commentedon Nov 16, 2017
Akansh Gulati (@akanshgulati) AFAIK this has been live since September. I'm on version 1.18.0 and it works
akanshgulati commentedon Nov 16, 2017
rhymes (@rhymes) I tried using
cmd + zto 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?rhymes commentedon Nov 16, 2017
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.