visual-studio-code

See unsaved changes in vscode


Sometimes when closing, VSCode asks "Do you want to save the changes you made to file?" 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.

How can I see the diff between the saved version of a file, and the version in the editor window? I'd prefer a "show diff" option in the dialogue, but I'll settle for a command line diff command.

I'm using ubuntu 20.04.


Solution

  • I had a similar problem using VSCode version 1.52.1 on MacOS.

    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."