I thought VS Code saves all the relevant metadata in .vscode
folder and .code-workspace
file and as these are contained within the workspace folder I assumed it's all self-contained and shouldn't cause problems when moved. But apparently I was gravely mistaken.
After moving my workspace folder to a new location and altering folder paths saved in .code-workspace
file accordingly all my opened editor panes and the bottom panel are gone. What I have now is a nice Welcome window.
I'm aware of what the official guide recommends, but that's only moving .code-worskpace
metafile - the folder still stays in place.
I've just run into the same issue. My workspace wasn't saved to a file at all (I just use the "Open with Code" option on each project folder), and the Save Workspace As option didn't help as it just created a JSON file with a couple of empty objects in it (which probably makes sense as I haven't really modified any workspace settings, I just want to preserve my open editors and things like that).
On Windows at least, it seems that those kinds of "workspace" settings are actually stored within subfolders of %APPDATA%\Code\User\workspaceStorage, and an SQLite database file is used to store the actual settings, so this is what I ended up doing:
Move your folder to the new location on disk (close all VS Code windows first)
Open the new folder location with VS Code (you'll just get the Welcome tab at this stage, but we just need it to create a settings storage folder for the new location). Then close VS code again.
Open %APPDATA%\Code\User\workspaceStorage in File Explorer, go into each subfolder and open workspace.json (in any old text editor). In my case at least, it only contains a folder property, which is path of the folder that this settings folder relates to (but just changing this won't help us at all, it was the first thing I tried). Use this to figure out which of these subfolders relate to the old and new paths.
Copy state.vscdb from old to new, and delete state.vscdb.backup in new.
Open state.vscdb in new in some sort of SQLite database file editor (I used DB Browser for SQLite and it worked fine, but there's also SQLiteStudio which looks like it might be better in general).
Run an UPDATE query to update all the paths in the database. They seem to be stored in three different formats/levels of escaping - between folders there can be a forward slash, two backslashes, or four backslashes. In my case I wanted to move my project folder from the root of my Windows user folder into my usual documents folder which is within OneDrive, so my query was along the lines of the following, as I only needed to change the middle section of each path. You might have to do something more complicated if you are moving to a different drive for example (would need to have a look at all the existing paths in the database to see how they are encoded).
UPDATE `ItemTable` SET `value` = REPLACE(REPLACE(REPLACE(`value`, 'User/Project', 'User/OneDrive/Documents/Project'), 'User\\Project', 'User\\OneDrive\\Documents\\Project'), 'User\\\\Project', 'User\\\\OneDrive\\\\Documents\\\\Project')
After saving the database, I just opened the new folder in VS Code, and everything seems to have loaded up exactly as it was in the old location :)
(Also just in case anyone is curious, the subfolder names in workspaceStorage seem to be some sort of hash based on the path, because if you delete the subfolder that relates to a folder you've previously opened in VS Code and then open that folder in Code again, it recreates the same subfolder name. So that means just updating the old workspace.json and database file in-place won't work)