Philip
Philip

Reputation: 73

How to save workspace state in VSCode and restore on another device?

I usually work on multiple local devices and do remote SSH works to different servers. Let's take these 3 machines as example:

Expected workflow:

In the morning, I opened VSCode on Local Windows and SSH into Remote Linux. I opened directory /www/wwwroot/dev.example.com/ as root of workspace. I opened FileA and FileB and split them into 2 columns layout. After saving all editings, I clicked File > Save Workspace As... Then I selected location /www/wwwroot/ and save the workspace file as .project1.code-workspace

In the afternoon. I opened VSCode on Local macOS and SSH into Remote Linux. I opened directory /www/wwwroot/dev.example.com/. I clicked File > Open Workspace from File... Then selected /www/wwwroot/.project1.code-workspace. I expect it to restore the state with FileA and FileB opened and split into 2 columns layout.

Problem

No file is opened. Layout is not restore. This is the content of .project1.code-workspace

{
    "folders": [
        {
            "path": "dev.example.com"
        }
    ]
}

Tests

I tried to save the workspace file at the root of project directory. But still not restoring anything.

I tried to save the workspace file at the Local Windows and share to Local macOS. But still not restoring anything.

I tried to save the workspace file at the Remote Linux and closed the VScode. Then open new window of VScode. SSH again and open the workspace file. But still not restoring anything.

Can anyone tell me what I am missing or did I misunderstood the function of workspace?

Upvotes: 0

Views: 188

Answers (1)

Mr Jxtr
Mr Jxtr

Reputation: 118

You can try to set workspace-level settings on your workspace-level settings.json.

Try to add these lines or toggle them in the settings menu.

"folders": [
    {
        "path": "dev.example.com"
    }
],
"settings": {
    "window.restoreWindows": "all",
    "workbench.editor.restoreViewState": true,

I never had this issue, as I only use a Windows device. If it still persists, it might be due to the multiple operating systems you are using.

Upvotes: -1

Related Questions