mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
[PTRun][VSCode]Add path existence check for windows+wsl env (#30821)
This commit is contained in:
parent
3802e91a05
commit
52e919925b
@ -46,6 +46,11 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
|
||||
path = path[1..];
|
||||
}
|
||||
|
||||
if (!DoesPathExist(path, workspaceEnv.Value, machineName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var folderName = Path.GetFileName(path);
|
||||
|
||||
// Check we haven't returned '' if we have a path like C:\
|
||||
@ -67,6 +72,24 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
|
||||
};
|
||||
}
|
||||
|
||||
private bool DoesPathExist(string path, WorkspaceEnvironment workspaceEnv, string machineName)
|
||||
{
|
||||
if (workspaceEnv == WorkspaceEnvironment.Local || workspaceEnv == WorkspaceEnvironment.RemoteWSL)
|
||||
{
|
||||
var resolvedPath = path;
|
||||
|
||||
if (workspaceEnv == WorkspaceEnvironment.RemoteWSL)
|
||||
{
|
||||
resolvedPath = $"\\\\wsl$\\{machineName}{resolvedPath.Replace('/', '\\')}";
|
||||
}
|
||||
|
||||
return Directory.Exists(resolvedPath) || File.Exists(resolvedPath);
|
||||
}
|
||||
|
||||
// If the workspace environment is not Local or WSL, assume the path exists
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<VSCodeWorkspace> Workspaces
|
||||
{
|
||||
get
|
||||
|
Loading…
Reference in New Issue
Block a user