VS CODE - disable UNDO command after file was closed - visual-studio-code

If I'm making some files changes then close it and then reopen it, I will be able to undo those changes. How can I disable this behaviour that only changes made in the current open session can be reverted?
PS: this behaviour was not present for older versions of VS code.

See v1.45 Release Notes:
Disable persistent Undo
Last milestone, changed the Undo/Redo stack to be persisted when you
close a file and reopen it. Not everyone wanted this new feature, so
there is now a setting, files.restoreUndoStack, to disable
persistent Undo.
[Additional info: see v1.46 release notes - you can undo even in files that were closed and remain closed.]

Open VS code
Click on manage {bottom-left}
Click settings
Search undo
Uncheck restore undo stack

Related

How to change VS Code's merge conflict layout?

I use VS CODE for version control (using git).
Every time I had a conflict, VS CODE showed me with a layout where I could see all the changes in one window:
However, with no advice, it change to a weird 3 windowed design where I can't understand anything.
Does someone know how can I go back to the first design?
Go to VS Code settings
Untick the Git: Merge Editor setting
Now you should be able to see the previous merge layout.
This feature (3 way merge editor) can be enabled by setting git.mergeEditor to true and will be enabled by default in future releases.
You can set it back to false to go back to the previous design as you want.
This new 3-way merge editor seems to have a terrible UX issue. For me simply switching to merge editor to 'false' doesn't work as below:
git.mergeEditor = false
After this editor completely stopped showing me any merge conflict line.
I have to finally do like this to revert back to original merge conflict view.
"diffEditor.codeLens": true,
"git.mergeEditor": false
Hit ctrl+shift+p to open command pallet and open the settings json by typing Preferences: Open User Settings (JSON) (or start typing 'settings' and this will come up)
In the main JSON object add "git.mergeEditor": false (insert comma beforehand if needed)
Hit ctrl+shift+p and type Developer: Reload Window to reload the windo.
The old type of merge editor should be back.. but you may need to wait a minute to get the full UI back (on my machine, the accept incoming buttons etc. didn't come back for a little).
Update 2023 in case the conflict UI has crashed/not displayed
When you rebase a file with embedded conflicts within conflicts VScode's in- file-conflict-display(blue/green UI) might glitch due to too-many git markers present, rendering merge impossible without CLI.
Apply workaround by enabling and switching to 3 way conflicts window.
enable merge editor (by searching the settings or modifying vscode config file locally)
use vscode's merge display by going to Source Control tab then clic the file with ! exclamation mark before the name of the file
solve the maximum number of conflict using the new 3 windows conflict UI (remember current and incoming are inverted in case of rebasing)
go back to normal file UI and the classic in-file-conflict-UI (green/blue) should be back online
finally git add . && git rebase --continue && :wq (vim) in case of rebase to pass to the next commit to handle.
Rule of Thumb: Remember to always create a temporary local branch of your feature before merging/rebasing your feature branch before PR. This will be used as backup to keep the design intent in mind. Then always run code(and lint) to check for obvious typos/merge artifacts (ie these git flags or unclosed loops/functions).

How can I get VS Code to give a heads up when deleting a file?

I accidentally deleted a whole project without commiting but the thing is that VS Code doesn't give me a confirmation prompt when deleting a file/folder.
Is there a way to get a heads up when I'm about to delete something? Thanks.
Use the setting "explorer.confirmDelete": true,, this will prompt a confirmation screen.
Another setting that helps my sanity in this situation.
"files.enableTrash": true, will move files to the OS trash instead of permanently deleting. This way you can go digging through the trash when this happens.
There is also
"workbench.editor.closeOnFileDelete": false which will keep open files that were deleted in the editor. A nice secondary option when deleting something.
"workbench.editor.closeOnFileDelete": false which will keep open files that were deleted in the editor. A nice secondary option when deleting something.
Make sure to use VSCode 1.75+ (Jan. 2023): issue 126144 ("Do not close tabs when a file is deleted when tab is not loaded") has been fixed with commit 0a11eb and is available in VSCode Insiders today.
That way, you can switch branch without VSCode closing files without warning.

How to configure VS Code to automatically close deleted files when switching branches?

Is there a way in VS Code to have it automatically close deleted file tabs when switching branches? I tend to switch branches in Tower and when I go back to VS Code a bunch of deleted files still show as open tabs. This causes confusion when I do a rename across the project since it readds the file back to the project at that point.
Is there a way to fix this to have it close deleted file tabs when switching branches?
I think you want to enable:
"workbench.editor.closeOnFileDelete": true, // default is false
Controls whether editors showing a file that was opened during the
session should close automatically when getting deleted or renamed by
some other process. Disabling this will keep the editor open on such
an event. Note that deleting from within the application will always
close the editor and that dirty files will never close to preserve
your data.
The files would be deleted immediately in vscode when deleted in another application - if that is what you want, not only when you switch branches.

How do I stop VScode from remembering the saved state of closed files?

Specifically, I don't want vscode to remember my cursor position or code folding in files that I've closed out of. I've looked all throughout the settings and can't seem to find it.
The functionality you are looking for was added in v.1.28.0. See release notes: do not restore state.
VS Code has always remembered the view state (cursor location, folded
sections, etc.) of a file even after the file was closed. There is now
a new setting workbench.editor.restoreViewState to drop this view
state when a file is closed. This allows you to always start at the
top of the file after reopening it.

How to read Release Notes inside VS Code

I have restarted my VS Code today and it got updated. When it was opened again, I got a tab with Release Notes and a few minutes later decided to open my project to see the changes in action.
However, when I did open the project, the Release Notes tab closed and now I can't find a way to access it specifically in VS Code.
Is there a way to do that?
Just open the Command Palette (Ctrl+Shift+P on Windows/Linux, CMD+Shift+P on macOs), type Show Release Notes, then hit Enter.
The release notes will be displayed on the same tab.
It is also available from the Help menu > Release Notes.
It opens the same tab showing your VS Code's version's release notes: