From f4df5528f1cc2f9884ec47a61e0ddb7dfc38179e Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 23 May 2023 20:03:55 +0800 Subject: [PATCH 1/7] Fix website --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index ad6eba3..f2bb0e5 100644 --- a/plugin.json +++ b/plugin.json @@ -6,7 +6,7 @@ "Author": "ricardosantos9521", "Version": "1.2.2", "Language": "csharp", - "Website": "https://github.com/ricardosantos9521/PowerToys/", + "Website": "https://github.com/taooceros/Flow.Plugin.VSCodeWorkspace", "ExecuteFileName": "Flow.Plugin.VSCodeWorkspaces.dll", "IsGlobal": false, "IcoPath": "Images\\code-light.png" From 21178daf4aad55bcfa2ceabc5a01fc579e4143b8 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 23 May 2023 20:09:03 +0800 Subject: [PATCH 2/7] Update to .net 7 --- Flow.Plugin.VSCodeWorkspaces.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Flow.Plugin.VSCodeWorkspaces.csproj b/Flow.Plugin.VSCodeWorkspaces.csproj index f802230..fa1d655 100644 --- a/Flow.Plugin.VSCodeWorkspaces.csproj +++ b/Flow.Plugin.VSCodeWorkspaces.csproj @@ -1,6 +1,6 @@ - + - net6.0-windows + net7.0-windows {4D971245-7A70-41D5-BAA0-DDB5684CAF51} Properties Flow.Plugin.VSCodeWorkspaces @@ -44,7 +44,7 @@ - + From 05d091f449bcdb2b17168f1117d7aeb3c70928c4 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 23 May 2023 20:22:24 +0800 Subject: [PATCH 3/7] Add context menu to open folder --- Main.cs | 24 +++++++++++++++++++++++- Properties/Resources.Designer.cs | 18 ++++++++++++++++++ Properties/Resources.resx | 6 ++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Main.cs b/Main.cs index 8096813..d8b2cc9 100644 --- a/Main.cs +++ b/Main.cs @@ -17,7 +17,7 @@ namespace Flow.Plugin.VSCodeWorkspaces using VSCodeHelper; using WorkspacesHelper; - public class Main : IPlugin, IPluginI18n, ISettingProvider + public class Main : IPlugin, IPluginI18n, ISettingProvider, IContextMenu { internal static PluginInitContext _context { get; private set; } @@ -193,5 +193,27 @@ public string GetTranslatedPluginDescription() { return Resources.PluginDescription; } + + public List LoadContextMenus(Result selectedResult) + { + List results = new(); + if (selectedResult.ContextData is VSCodeWorkspace ws && ws.TypeWorkspace == TypeWorkspace.Local) + { + results.Add(new Result + { + Title = Resources.OpenFolder, + SubTitle = Resources.OpenFolderSubTitle, + Icon = ws.VSCodeInstance.WorkspaceIcon, + TitleToolTip = Resources.OpenFolderSubTitle, + Action = c => + { + _context.API.OpenDirectory(SystemPath.RealPath(ws.RelativePath)); + return true; + }, + ContextData = ws, + }); + } + return results; + } } } diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index f76e3a8..a1c53c2 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -132,6 +132,24 @@ public static string In { } } + /// + /// 查找类似 Open Folder 的本地化字符串。 + /// + public static string OpenFolder { + get { + return ResourceManager.GetString("OpenFolder", resourceCulture); + } + } + + /// + /// 查找类似 Open folder in default file manager 的本地化字符串。 + /// + public static string OpenFolderSubTitle { + get { + return ResourceManager.GetString("OpenFolderSubTitle", resourceCulture); + } + } + /// /// 查找类似 Opens workspaces, remote machines (SSH or Codespaces) and containers, previously opened in VS Code. 的本地化字符串。 /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 2966271..9387afe 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -167,4 +167,10 @@ Extra Folder URI + + Open Folder + + + Open folder in default file manager + \ No newline at end of file From 9637c077e6c3a98b5a3dc0c3bb867a1566381540 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 23 May 2023 20:26:21 +0800 Subject: [PATCH 4/7] Add Ctrl+Enter hotkey to open folder --- Main.cs | 15 +++++++++++---- Properties/Resources.Designer.cs | 9 +++++++++ Properties/Resources.resx | 3 +++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Main.cs b/Main.cs index d8b2cc9..bc44e01 100644 --- a/Main.cs +++ b/Main.cs @@ -93,8 +93,8 @@ public List Query(Query query) } catch (Win32Exception) { - var name = $"Plugin: {_context.CurrentPluginMetadata.Name}"; - const string msg = "Can't Open this file"; + var name = $"{_context.CurrentPluginMetadata.Name}"; + string msg = Resources.OpenFail; _context.API.ShowMsg(name, msg, string.Empty); hide = false; } @@ -141,6 +141,13 @@ private Result CreateWorkspaceResult(VSCodeWorkspace ws) { try { + var modifierKeys = c.SpecialKeyState.ToModifierKeys(); + if (modifierKeys == System.Windows.Input.ModifierKeys.Control) + { + _context.API.OpenDirectory(SystemPath.RealPath(ws.RelativePath)); + return true; + } + var process = new ProcessStartInfo { FileName = ws.VSCodeInstance.ExecutablePath, @@ -155,8 +162,8 @@ private Result CreateWorkspaceResult(VSCodeWorkspace ws) } catch (Win32Exception) { - var name = $"Plugin: {_context.CurrentPluginMetadata.Name}"; - const string msg = "Can't Open this file"; + var name = $"{_context.CurrentPluginMetadata.Name}"; + string msg = Resources.OpenFail; _context.API.ShowMsg(name, msg, string.Empty); } return false; diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index a1c53c2..e304058 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -132,6 +132,15 @@ public static string In { } } + /// + /// 查找类似 Can't open this workspace 的本地化字符串。 + /// + public static string OpenFail { + get { + return ResourceManager.GetString("OpenFail", resourceCulture); + } + } + /// /// 查找类似 Open Folder 的本地化字符串。 /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 9387afe..5678ff2 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -167,6 +167,9 @@ Extra Folder URI + + Can't open this workspace + Open Folder From 7a23236b5e3ac8f8c63b23a5a1ea2ad419635ea5 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 23 May 2023 20:48:19 +0800 Subject: [PATCH 5/7] Fix VSCodium support --- VSCodeHelper/VSCodeInstances.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/VSCodeHelper/VSCodeInstances.cs b/VSCodeHelper/VSCodeInstances.cs index e6871c6..64e869d 100644 --- a/VSCodeHelper/VSCodeInstances.cs +++ b/VSCodeHelper/VSCodeInstances.cs @@ -71,7 +71,7 @@ public static void LoadVSCodeInstances() _systemPath = Environment.GetEnvironmentVariable("PATH") ?? ""; var paths = _systemPath.Split(";").Where(x => x.Contains("VS Code", StringComparison.OrdinalIgnoreCase) || - x.Contains("VSCodium", StringComparison.OrdinalIgnoreCase) || + x.Contains("codium", StringComparison.OrdinalIgnoreCase) || x.Contains("vscode", StringComparison.OrdinalIgnoreCase)); foreach (var path in paths) { @@ -80,7 +80,7 @@ public static void LoadVSCodeInstances() var files = Directory.EnumerateFiles(path).Where(x => (x.Contains("code", StringComparison.OrdinalIgnoreCase) || - x.Contains("VSCodium", StringComparison.OrdinalIgnoreCase)) + x.Contains("codium", StringComparison.OrdinalIgnoreCase)) && !x.EndsWith(".cmd", StringComparison.OrdinalIgnoreCase)).ToArray(); var iconPath = Path.GetDirectoryName(path); @@ -111,6 +111,11 @@ public static void LoadVSCodeInstances() version = "Code - Exploration"; instance.VSCodeVersion = VSCodeVersion.Exploration; } + else if (file.EndsWith("codium")) + { + version = "VSCodium"; + instance.VSCodeVersion = VSCodeVersion.Stable; + } if (version == string.Empty) continue; From a538d042a509f3a6230bf11abd7fc416e5e680ca Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 23 May 2023 20:50:44 +0800 Subject: [PATCH 6/7] Version update --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index f2bb0e5..dac7e0d 100644 --- a/plugin.json +++ b/plugin.json @@ -4,7 +4,7 @@ "ActionKeyword": "{", "Name": "VS Code Workspaces", "Author": "ricardosantos9521", - "Version": "1.2.2", + "Version": "1.3.0", "Language": "csharp", "Website": "https://github.com/taooceros/Flow.Plugin.VSCodeWorkspace", "ExecuteFileName": "Flow.Plugin.VSCodeWorkspaces.dll", From 4f7b971eac30632ed8f105ea94cc3c027a269776 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 23 May 2023 20:56:16 +0800 Subject: [PATCH 7/7] Update Resources.zh-CN.resx --- Properties/Resources.zh-CN.resx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index 05d24ca..54a6368 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -141,6 +141,15 @@ 位于 + + 无法打开工作区 + + + 打开文件夹 + + + 在默认文件管理器中打开文件夹 + 在 VS Code 中打开最近使用的工作区、远程计算机(SSH 或 Codespaces)和容器。