mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
[Run][New Plugin] VSCode Workspaces/Remote machines (#9050)
* vscode workspaces plugin for Powertoys Run
* reduce score
* make vscode workspaces dynamic instead of string to prevent exceptions
* change icons again
* remove unused images and PreserveNewest during build
* code refactoring
* show vscode ssh remote machines
* update score workspaces
* vscode workspaces plugin for Powertoys Run
* remove unused images and PreserveNewest during build
* code refactoring
* remove unused packages
* get ExecutablePath from AppData and use shell to vscode process
* ' instead of \"
* try using ((char)34) instead of '
* add comments
* translate windows paths
* remove unused code
* add vscodeworkspace to installer
* use the new naming convention for plugins
* sign VSCodeWorkspaces.dll
* reimplement ssh-config parser
* update spell-check
* use the new naming convention for community plugins
* minor adjustments
* add actionKeyword {
* prevent copyright
* add localization
* add github link
* bug fix after localization
* --new-window --enable-proposed-api ms-vscode-remote.remote-ssh
* change order by
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
* Update src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
* Update src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
* Update src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
* Update src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
* Update src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
* fix powertoys run settings not working
* update plugin description
Co-authored-by: ricar <ricar@ASUS>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f648ac44b2
commit
7e5fb876bb
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
|
||||
{
|
||||
public class ParseVSCodeUri
|
||||
{
|
||||
private static readonly Regex LocalWorkspace = new Regex("^file:///(.+)$", RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex RemoteSSHWorkspace = new Regex(@"^vscode-remote://ssh-remote\+(.+?(?=\/))(.+)$", RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex RemoteWSLWorkspace = new Regex(@"^vscode-remote://wsl\+(.+?(?=\/))(.+)$", RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex CodespacesWorkspace = new Regex(@"^vscode-remote://vsonline\+(.+?(?=\/))(.+)$", RegexOptions.Compiled);
|
||||
|
||||
public static (TypeWorkspace? TypeWorkspace, String MachineName, String Path) GetTypeWorkspace(string uri)
|
||||
{
|
||||
if (LocalWorkspace.IsMatch(uri))
|
||||
{
|
||||
var match = LocalWorkspace.Match(uri);
|
||||
|
||||
if (match.Groups.Count > 1)
|
||||
{
|
||||
return (TypeWorkspace.Local, null, match.Groups[1].Value);
|
||||
}
|
||||
}
|
||||
else if (RemoteSSHWorkspace.IsMatch(uri))
|
||||
{
|
||||
var match = RemoteSSHWorkspace.Match(uri);
|
||||
|
||||
if (match.Groups.Count > 1)
|
||||
{
|
||||
return (TypeWorkspace.RemoteSSH, match.Groups[1].Value, match.Groups[2].Value);
|
||||
}
|
||||
}
|
||||
else if (RemoteWSLWorkspace.IsMatch(uri))
|
||||
{
|
||||
var match = RemoteWSLWorkspace.Match(uri);
|
||||
|
||||
if (match.Groups.Count > 1)
|
||||
{
|
||||
return (TypeWorkspace.RemoteWSL, match.Groups[1].Value, match.Groups[2].Value);
|
||||
}
|
||||
}
|
||||
else if (CodespacesWorkspace.IsMatch(uri))
|
||||
{
|
||||
var match = CodespacesWorkspace.Match(uri);
|
||||
|
||||
if (match.Groups.Count > 1)
|
||||
{
|
||||
return (TypeWorkspace.Codespaces, String.Empty, match.Groups[2].Value);
|
||||
}
|
||||
}
|
||||
|
||||
return (null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
|
||||
{
|
||||
public class VSCodeStorageFile
|
||||
{
|
||||
public openedPathsList openedPathsList { get; set; }
|
||||
}
|
||||
|
||||
public class openedPathsList
|
||||
{
|
||||
public List<dynamic> workspaces3 { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.Properties;
|
||||
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
|
||||
{
|
||||
public class VSCodeWorkspace
|
||||
{
|
||||
public string Path { get; set; }
|
||||
|
||||
public string RelativePath { get; set; }
|
||||
|
||||
public string FolderName { get; set; }
|
||||
|
||||
public string ExtraInfo { get; set; }
|
||||
|
||||
public TypeWorkspace TypeWorkspace { get; set; }
|
||||
|
||||
public VSCodeInstance VSCodeInstance { get; set; }
|
||||
|
||||
public string WorkspaceTypeToString()
|
||||
{
|
||||
switch (TypeWorkspace)
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TypeWorkspace
|
||||
{
|
||||
Local = 1,
|
||||
Codespaces = 2,
|
||||
RemoteWSL = 3,
|
||||
RemoteSSH = 4,
|
||||
RemoteContainers = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
|
||||
{
|
||||
public class VSCodeWorkspacesApi
|
||||
{
|
||||
public VSCodeWorkspacesApi() { }
|
||||
|
||||
public List<VSCodeWorkspace> Workspaces
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
var results = new List<VSCodeWorkspace>();
|
||||
|
||||
foreach (var vscodeInstance in VSCodeInstances.instances)
|
||||
{
|
||||
// storage.json contains opened Workspaces
|
||||
var vscode_storage = Path.Combine(vscodeInstance.AppData, "storage.json");
|
||||
|
||||
if (File.Exists(vscode_storage))
|
||||
{
|
||||
var fileContent = File.ReadAllText(vscode_storage);
|
||||
|
||||
try
|
||||
{
|
||||
VSCodeStorageFile vscodeStorageFile = JsonConvert.DeserializeObject<VSCodeStorageFile>(fileContent);
|
||||
|
||||
if (vscodeStorageFile != null)
|
||||
{
|
||||
foreach (var workspaceUri in vscodeStorageFile.openedPathsList.workspaces3)
|
||||
{
|
||||
if (workspaceUri != null && workspaceUri is String)
|
||||
{
|
||||
string unescapeUri = Uri.UnescapeDataString(workspaceUri);
|
||||
var typeWorkspace = ParseVSCodeUri.GetTypeWorkspace(unescapeUri);
|
||||
if (typeWorkspace.TypeWorkspace.HasValue)
|
||||
{
|
||||
var folderName = Path.GetFileName(unescapeUri);
|
||||
results.Add(new VSCodeWorkspace()
|
||||
{
|
||||
Path = workspaceUri,
|
||||
RelativePath = typeWorkspace.Path,
|
||||
FolderName = folderName,
|
||||
ExtraInfo = typeWorkspace.MachineName,
|
||||
TypeWorkspace = typeWorkspace.TypeWorkspace.Value,
|
||||
VSCodeInstance = vscodeInstance
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var message = $"Failed to deserialize ${vscode_storage}";
|
||||
Log.Exception(message, ex, GetType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user