diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeStorageWorkspaceFile.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeStorageWorkspaceFile.cs new file mode 100644 index 000000000000..89bbe2c83f5e --- /dev/null +++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeStorageWorkspaceFile.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper +{ + // v1.64 uses AppData\Roaming\Code\Backups\workspaces + public class VSCodeStorageWorkspaceFile + { + [JsonPropertyName("folderWorkspaceInfos")] + public List FolderWorkspaceInfos { get; set; } + } +} diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs index 635b96c7b1c4..c33da4906d52 100644 --- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs +++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs @@ -62,6 +62,9 @@ public List Workspaces // storage.json contains opened Workspaces var vscode_storage = Path.Combine(vscodeInstance.AppData, "storage.json"); + // Backups/workspace.json - vscode v1.64 or later + var vscode_storage_workspaces = Path.Combine(vscodeInstance.AppData, "Backups/workspaces.json"); + if (File.Exists(vscode_storage)) { var fileContent = File.ReadAllText(vscode_storage); @@ -70,7 +73,7 @@ public List Workspaces { VSCodeStorageFile vscodeStorageFile = JsonSerializer.Deserialize(fileContent); - if (vscodeStorageFile != null) + if (vscodeStorageFile != null && vscodeStorageFile.OpenedPathsList != null) { // for previous versions of vscode if (vscodeStorageFile.OpenedPathsList.Workspaces3 != null) @@ -98,6 +101,32 @@ public List Workspaces uri = entry.Workspace.ConfigPath; } + var workspace = ParseVSCodeUri(uri, vscodeInstance, isWorkspaceFile); + if (workspace != null) + { + results.Add(workspace); + } + } + } + } + else if (File.Exists(vscode_storage_workspaces)) + { + // vscode 1.64 or later + fileContent = File.ReadAllText(vscode_storage_workspaces); + VSCodeStorageWorkspaceFile vscodeStorageWorkspaceFile = JsonSerializer.Deserialize(fileContent); + + if (vscodeStorageWorkspaceFile.FolderWorkspaceInfos != null) + { + foreach (var entry in vscodeStorageWorkspaceFile.FolderWorkspaceInfos) + { + bool isWorkspaceFile = false; + var uri = entry.FolderUri; + if (entry.Workspace != null && entry.Workspace.ConfigPath != null) + { + isWorkspaceFile = true; + uri = entry.Workspace.ConfigPath; + } + var workspace = ParseVSCodeUri(uri, vscodeInstance, isWorkspaceFile); if (workspace != null) {