diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs
index c013015d6b..6f5ae4902e 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs
@@ -41,20 +41,20 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
// Search opened workspaces
_workspacesApi.Workspaces.ForEach(a =>
{
- var title = $"{a.FolderName}";
+ var title = a.WorkspaceType == WorkspaceType.ProjectFolder ? a.FolderName : a.FolderName.Replace(".code-workspace", $" ({Resources.Workspace})");
- var typeWorkspace = a.WorkspaceTypeToString();
- if (a.TypeWorkspace != TypeWorkspace.Local)
+ var typeWorkspace = a.WorkspaceEnvironmentToString();
+ if (a.WorkspaceEnvironment != WorkspaceEnvironment.Local)
{
title = $"{title}{(a.ExtraInfo != null ? $" - {a.ExtraInfo}" : string.Empty)} ({typeWorkspace})";
}
- var tooltip = new ToolTipData(title, $"{Resources.Workspace}{(a.TypeWorkspace != TypeWorkspace.Local ? $" {Resources.In} {typeWorkspace}" : string.Empty)}: {SystemPath.RealPath(a.RelativePath)}");
+ var tooltip = new ToolTipData(title, $"{(a.WorkspaceType == WorkspaceType.WorkspaceFile ? Resources.Workspace : Resources.ProjectFolder)}{(a.WorkspaceEnvironment != WorkspaceEnvironment.Local ? $" {Resources.In} {typeWorkspace}" : string.Empty)}: {SystemPath.RealPath(a.RelativePath)}");
results.Add(new Result
{
Title = title,
- SubTitle = $"{Resources.Workspace}{(a.TypeWorkspace != TypeWorkspace.Local ? $" {Resources.In} {typeWorkspace}" : string.Empty)}: {SystemPath.RealPath(a.RelativePath)}",
+ SubTitle = $"{(a.WorkspaceType == WorkspaceType.WorkspaceFile ? Resources.Workspace : Resources.ProjectFolder)}{(a.WorkspaceEnvironment != WorkspaceEnvironment.Local ? $" {Resources.In} {typeWorkspace}" : string.Empty)}: {SystemPath.RealPath(a.RelativePath)}",
Icon = a.VSCodeInstance.WorkspaceIcon,
ToolTipData = tooltip,
Action = c =>
@@ -66,7 +66,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
{
FileName = a.VSCodeInstance.ExecutablePath,
UseShellExecute = true,
- Arguments = $"--folder-uri {a.Path}",
+ Arguments = a.WorkspaceType == WorkspaceType.ProjectFolder ? $"--folder-uri {a.Path}" : $"--file-uri {a.Path}",
WindowStyle = ProcessWindowStyle.Hidden,
};
Process.Start(process);
@@ -142,23 +142,23 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
}
results.ForEach(x =>
- {
- if (x.Score == 0)
- {
- x.Score = 100;
- }
+ {
+ if (x.Score == 0)
+ {
+ x.Score = 100;
+ }
- // intersect the title with the query
- var intersection = Convert.ToInt32(x.Title.ToLowerInvariant().Intersect(query.Search.ToLowerInvariant()).Count() * query.Search.Count());
- var differenceWithQuery = Convert.ToInt32((x.Title.Count() - intersection) * query.Search.Count() * 0.7);
- x.Score = x.Score - differenceWithQuery + intersection;
+ // intersect the title with the query
+ var intersection = Convert.ToInt32(x.Title.ToLowerInvariant().Intersect(query.Search.ToLowerInvariant()).Count() * query.Search.Count());
+ var differenceWithQuery = Convert.ToInt32((x.Title.Count() - intersection) * query.Search.Count() * 0.7);
+ x.Score = x.Score - differenceWithQuery + intersection;
- // if is a remote machine give it 12 extra points
- if (x.ContextData is VSCodeRemoteMachine)
- {
- x.Score = Convert.ToInt32(x.Score + (intersection * 2));
- }
- });
+ // if is a remote machine give it 12 extra points
+ if (x.ContextData is VSCodeRemoteMachine)
+ {
+ x.Score = Convert.ToInt32(x.Score + (intersection * 2));
+ }
+ });
results = results.OrderByDescending(x => x.Score).ToList();
if (query.Search == string.Empty || query.Search.Replace(" ", string.Empty) == string.Empty)
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.Designer.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.Designer.cs
index 6a4647d70e..dd24288924 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.Designer.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -87,6 +87,15 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Project Folder.
+ ///
+ internal static string ProjectFolder {
+ get {
+ return ResourceManager.GetString("ProjectFolder", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to SSH remote machine.
///
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
index fb8ab78401..a155262872 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
@@ -140,10 +140,14 @@
Workspace
- It refers to the "Visual Studio Code workspace"
+ It refers to the Visual Studio Code .code-workspace
Dev Container
As in "Visual Studio Code Dev Container workspace "
+
+ Project Folder
+ It refers to the Visual Studio Code Project Folders
+
\ No newline at end of file
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs
index 47e9245440..db224d1633 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs
@@ -18,7 +18,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
private static readonly Regex DevContainerWorkspace = new Regex(@"^vscode-remote://dev-container\+(.+?(?=\/))(.+)$", RegexOptions.Compiled);
- public static (TypeWorkspace? TypeWorkspace, string MachineName, string Path) GetTypeWorkspace(string uri)
+ public static (WorkspaceEnvironment? WorkspaceEnvironment, string MachineName, string Path) GetWorkspaceEnvironment(string uri)
{
if (LocalWorkspace.IsMatch(uri))
{
@@ -26,7 +26,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
if (match.Groups.Count > 1)
{
- return (TypeWorkspace.Local, null, match.Groups[1].Value);
+ return (WorkspaceEnvironment.Local, null, match.Groups[1].Value);
}
}
else if (RemoteSSHWorkspace.IsMatch(uri))
@@ -35,7 +35,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
if (match.Groups.Count > 1)
{
- return (TypeWorkspace.RemoteSSH, match.Groups[1].Value, match.Groups[2].Value);
+ return (WorkspaceEnvironment.RemoteSSH, match.Groups[1].Value, match.Groups[2].Value);
}
}
else if (RemoteWSLWorkspace.IsMatch(uri))
@@ -44,7 +44,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
if (match.Groups.Count > 1)
{
- return (TypeWorkspace.RemoteWSL, match.Groups[1].Value, match.Groups[2].Value);
+ return (WorkspaceEnvironment.RemoteWSL, match.Groups[1].Value, match.Groups[2].Value);
}
}
else if (CodespacesWorkspace.IsMatch(uri))
@@ -53,7 +53,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
if (match.Groups.Count > 1)
{
- return (TypeWorkspace.Codespaces, null, match.Groups[2].Value);
+ return (WorkspaceEnvironment.Codespaces, null, match.Groups[2].Value);
}
}
else if (DevContainerWorkspace.IsMatch(uri))
@@ -62,7 +62,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
if (match.Groups.Count > 1)
{
- return (TypeWorkspace.DevContainer, null, match.Groups[2].Value);
+ return (WorkspaceEnvironment.DevContainer, null, match.Groups[2].Value);
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs
index 9685b11156..fb5a78d118 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs
@@ -17,27 +17,29 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
public string ExtraInfo { get; set; }
- public TypeWorkspace TypeWorkspace { get; set; }
+ public WorkspaceEnvironment WorkspaceEnvironment { get; set; }
+
+ public WorkspaceType WorkspaceType { get; set; }
public VSCodeInstance VSCodeInstance { get; set; }
- public string WorkspaceTypeToString()
+ public string WorkspaceEnvironmentToString()
{
- switch (TypeWorkspace)
+ switch (WorkspaceEnvironment)
{
- case TypeWorkspace.Local: return Resources.TypeWorkspaceLocal;
- case TypeWorkspace.Codespaces: return "Codespaces";
- case TypeWorkspace.RemoteContainers: return Resources.TypeWorkspaceContainer;
- case TypeWorkspace.RemoteSSH: return "SSH";
- case TypeWorkspace.RemoteWSL: return "WSL";
- case TypeWorkspace.DevContainer: return Resources.TypeWorkspaceDevContainer;
+ case WorkspaceEnvironment.Local: return Resources.TypeWorkspaceLocal;
+ case WorkspaceEnvironment.Codespaces: return "Codespaces";
+ case WorkspaceEnvironment.RemoteContainers: return Resources.TypeWorkspaceContainer;
+ case WorkspaceEnvironment.RemoteSSH: return "SSH";
+ case WorkspaceEnvironment.RemoteWSL: return "WSL";
+ case WorkspaceEnvironment.DevContainer: return Resources.TypeWorkspaceDevContainer;
}
return string.Empty;
}
}
- public enum TypeWorkspace
+ public enum WorkspaceEnvironment
{
Local = 1,
Codespaces = 2,
@@ -46,4 +48,10 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
RemoteContainers = 5,
DevContainer = 6,
}
+
+ public enum WorkspaceType
+ {
+ ProjectFolder = 1,
+ WorkspaceFile = 2,
+ }
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceEntry.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceEntry.cs
index 44412ce9b9..1f245489bc 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceEntry.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceEntry.cs
@@ -13,5 +13,8 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
[JsonPropertyName("label")]
public string Label { get; set; }
+
+ [JsonPropertyName("workspace")]
+ public VSCodeWorkspaceProperty Workspace { get; set; }
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceProperty.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceProperty.cs
new file mode 100644
index 0000000000..eeec991661
--- /dev/null
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceProperty.cs
@@ -0,0 +1,17 @@
+// 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.Text.Json.Serialization;
+
+namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
+{
+ public class VSCodeWorkspaceProperty
+ {
+ [JsonPropertyName("id")]
+ public string Id { get; set; }
+
+ [JsonPropertyName("configPath")]
+ public string ConfigPath { 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 aafa527924..635b96c7b1 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
@@ -18,13 +18,13 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
{
}
- private VSCodeWorkspace ParseVSCodeUri(string uri, VSCodeInstance vscodeInstance)
+ private VSCodeWorkspace ParseVSCodeUri(string uri, VSCodeInstance vscodeInstance, bool isWorkspaceFile = false)
{
if (uri != null && uri is string)
{
string unescapeUri = Uri.UnescapeDataString(uri);
- var typeWorkspace = WorkspacesHelper.ParseVSCodeUri.GetTypeWorkspace(unescapeUri);
- if (typeWorkspace.TypeWorkspace.HasValue)
+ var typeWorkspace = WorkspacesHelper.ParseVSCodeUri.GetWorkspaceEnvironment(unescapeUri);
+ if (typeWorkspace.WorkspaceEnvironment.HasValue)
{
var folderName = Path.GetFileName(unescapeUri);
@@ -38,10 +38,11 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
return new VSCodeWorkspace()
{
Path = uri,
+ WorkspaceType = isWorkspaceFile ? WorkspaceType.WorkspaceFile : WorkspaceType.ProjectFolder,
RelativePath = typeWorkspace.Path,
FolderName = folderName,
ExtraInfo = typeWorkspace.MachineName,
- TypeWorkspace = typeWorkspace.TypeWorkspace.Value,
+ WorkspaceEnvironment = typeWorkspace.WorkspaceEnvironment.Value,
VSCodeInstance = vscodeInstance,
};
}
@@ -76,10 +77,10 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
{
foreach (var workspaceUri in vscodeStorageFile.OpenedPathsList.Workspaces3)
{
- var uri = ParseVSCodeUri(workspaceUri, vscodeInstance);
- if (uri != null)
+ var workspace = ParseVSCodeUri(workspaceUri, vscodeInstance);
+ if (workspace != null)
{
- results.Add(uri);
+ results.Add(workspace);
}
}
}
@@ -87,12 +88,20 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
// vscode v1.55.0 or later
if (vscodeStorageFile.OpenedPathsList.Entries != null)
{
- foreach (var workspaceUri in vscodeStorageFile.OpenedPathsList.Entries.Select(x => x.FolderUri))
+ foreach (var entry in vscodeStorageFile.OpenedPathsList.Entries)
{
- var uri = ParseVSCodeUri(workspaceUri, vscodeInstance);
- if (uri != null)
+ bool isWorkspaceFile = false;
+ var uri = entry.FolderUri;
+ if (entry.Workspace != null && entry.Workspace.ConfigPath != null)
{
- results.Add(uri);
+ isWorkspaceFile = true;
+ uri = entry.Workspace.ConfigPath;
+ }
+
+ var workspace = ParseVSCodeUri(uri, vscodeInstance, isWorkspaceFile);
+ if (workspace != null)
+ {
+ results.Add(workspace);
}
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/plugin.json b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/plugin.json
index 290fd60200..9645f81afe 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/plugin.json
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/plugin.json
@@ -4,7 +4,7 @@
"ActionKeyword": "{",
"Name": "VS Code Workspaces",
"Author": "ricardosantos9521",
- "Version": "1.0.0",
+ "Version": "1.1.0",
"Language": "csharp",
"Website": "https://github.com/ricardosantos9521/PowerToys/",
"ExecuteFileName": "Community.PowerToys.Run.Plugin.VSCodeWorkspaces.dll",