Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See unsaved changes in vscode

Sometimes when closing vscode, or a tab therein, I get a dialogue asking "Do you want to save the changes you made to filename?" However, the unsaved edits are actually from a previous session that was closed without such a query, probably when turning off the computer, so I can't remember if it was meaningful edits, or maybe just an accidental key-press, like a shortcut gone wrong; and doing undo to revisit the last edits doesn't work either.

My question: How can I see the diff between the saved version of a file, and the version in the editor window? I think it would be nicest just to have a "show diff" option in the dialogue, but for now I'm also happy with a command line diff command.

I'm using ubuntu 20.04.

like image 328
user313032 Avatar asked Jan 24 '21 18:01

user313032


People also ask

How do I recover an unsaved project in Visual Studio?

Found my lost project by going to "C:\Users{Username}\AppData\Local", right clicking on the Local folder, clicking on "Restore previous versions," selecting the appropriate version, and clicking the "Open" button.

How do I view VS Code history?

When you have repository open in Visual Studio code, you can execute the command Git: View History (git log) from the command Plate. This will open the Git History Window with all change logs for the repository. You can then select individual commits for detailed change logs for each of them.

Does VS Code have edit history?

There isn't any option in Visual Studio Code to see file history. If you are using Git, then you can use Visual Studio Code extension Git History to see the file changes after each commit and compare with previous commits.


1 Answers

I'm using VSCode version 1.52.1 on MacOS and I had a similar problem that may not be the same problem, but I'm guessing it will work for you as well.

When you're in the Explorer view, in the upper left part of Explorer you have your "Open Editors." If that shows a dot to the left indicating that the buffer has changes in it, you can right click the file name and select "Compare with Saved." This will open another buffer to the side that will show you any unsaved changes.

To get rid of that window (it took me a bit to figure this out I'm sorry to say!), you can click the 'X' to the left of the extra buffer in "Open Editors."

Hope this works for you!

like image 130
craigching Avatar answered Sep 19 '22 13:09

craigching