I created a file with no title in vs code but suddenly closed the file without saving changes. Is there any way to recover it I tried the .config/code/backup folder but did not find the file?
Related
When I open a folder in vscode, any file that was ever not saved before closing vscode is re-opened as unsaved even though it may no longer exist.
Open any file of any type in a workspace
Modify the file
Close VScode without saving the file.
Re-open VSCode
The original file is loaded as unsaved (good)
Save the file, and close it
Close VSCode
Re-open VSCode
The original file is re-loaded as unsaved again (bad).
My VSCode session now loads close to 30 files on startup, even though they have all been saved and in some cases deleted. Even my settings.json file loads as unsaved.
Things I've tried:
Closing all files before exiting
Closing all files, workspace before exiting
Updating every vscode setting I can find relating to file closing and opening at shutdown/startup
Uninstalling vscode and reinstalling. Even after this, the same list of 30 files is loaded at workspace open
In the Windows \users\[user]\Appdata\roaming\Code directory, locate the storage.json file, open in editor.
Remove all of the entries in the OpenedPathsList section
Locate the windowsState.lastActiveWindow.BackupPath entry
Delete all of the subdirectories inside this folder name
EDIT This doesn't actually fix the problem - It just removes the symptoms.
I have a very annoying problem in my VScode setup.
I'm using WSL as a terminal to work on my projects and occasionally, mistype the name of one of the folder or file that I'm working with.
For example:
I accidentally created the Mainheader.js file in layout folder (without the capitalized L) therefore, I decided to rename the folder with a capital L.
Now on my React app, any changes made to MainHeader.js file will not be reflected. I did update the related import.
So I decided to delete the entire folder and recreate it with MainHeader.js but this is what I end up with.
The file is there in my folder but when I click on it, I get
"Unable to open Mainheader.js - File not found"
So I try to create it then I get this error:
Unable to create file 'wsl\path]to\MainHeader.js' that already exists when overwrite flag is not set
Has anyone run into this type of behavior in WSL before? It's quite annoying because the only workaround I've found so far is to create a completely different folder with a different name...
Any help would be appreciated. I can't really work like this.
I've been having the same problem for the past 2 days. I presume its a permissions issue, but unfortunately I don't know how to permanently fix it.
I did find this work-around though:
Open a new VS Code window. (I'd recommend closing any VS Code window that had
your project directory open.)
Create a duplicate or copy the contents of the problem file so you don't lose
your code.
Delete the problem file.
Now create the file again using VS Code. Go to File > New Text File. Next paste
in your code.
Now save your new file. Go to File > Save As and save your new file with at the same path + filename + extension that was giving you problems previously. VS Code should allow you to save the new file without any issue.
Now you can open this new VS Code window to your project directory and you should be able to continuing accessing the file that was a problem before.
Basically we just deleted the problem file and then created it again from scratch in a new VS Code window.
Hope this work-around works for you!
EDIT 09/20/2022
Following Baza86's answer here solved the issue for me. Seems like it was a permissions issue of sorts, but if you use the Remote-WSL extension VS code can directly access the linux filesystem.
How to run VScode in sudo mode in WSL2?
You may need add the case option to you options in the wsl config. The default is set to off, however you can set this to off, dir or force.
Open your wsl.conf using sudo with any text editor while running window subsystem Linux. The config file resides in /etc/wsl.conf. This file is used to configure settings per-distribution for Linux distros running on WSL 1 or WSL 2.
My default config looked like this yours may be different:
[automount]
options = "metadata"
add
[automount]
options = "metadata,case=dir"
Here is the official Microsoft docs for Advanced settings configuration in WSL - https://learn.microsoft.com/en-us/windows/wsl/wsl-config
The opened files on my VS Code are all enqueued for a review before I close them one by one. The problem is whenever my VS Code crash, it is NOT restoring my last "enqueued to review" opened files, instead it is restoring the opened files on its startup. The last opened file reopening after I close my VS Code without any crash is working as expected.
Is there any solution or configuration, that will make my VS Code restores the last opened saved files after crashing?
My User Settings:
"Files: Hot Exit" is set to onExitAndWindowClose.
Controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.
"Window: Restore Windows" is set to one. Will setting it to all makes difference?
Controls how windows are being reopened after a restart.
Visual Studio Code is showing non-existent files. For example, creating a file with the wrong name
doga.txt
Then correcting that name
dog.txt
Will often show doga.txt in the file search for days after. Clicking on that file throws an error and it disappears, only to reappear later. Reloading the window does not fix the problem. This is especially painful during git interactive rebasing.
How can I ensure VSC is always showing a correct representation of my files, directories and contents?
I gave a chance to Visual Studio Code as my primary editor. I had been using Notepad++ and afterwards I have been using Sublime Text 2 and 3 for few years. I do see potential of this editor and I really like it, but there is one thing I am strongly used to.
Notepad++ and Sublime Text has this feature, I can edit file and DON'T save it anywhere. After restart Notepad/Sublime Text this file is there ready for me.
Other workflow could be open any file from my local storage, close VS Code and start it again. This file will not open!
I know about that when I open folder and restart VS Code, folder is open and files as well. But is there any way how can I manage to have opened files after restart without having opened folder?
Edit: This is now implemented:
// Controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.
"files.hotExit": "onExit"
I use the insider release, and in the current version (1.3.0), vscode doesn't keep unsaved file. I think there is a feature request for that.
Got it: https://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/8568343-keep-unsaved-files-after-crash
You can vote for that feature, like I did !
On the other hand, You can tell in settings if you want to re-open previously opened folders, but not files.
"window.reopenFolders": "all"