mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[PTRun][VSCode]Add path existence check for windows+wsl env (#30821)
This commit is contained in:
@@ -46,6 +46,11 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
|
|||||||
path = path[1..];
|
path = path[1..];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!DoesPathExist(path, workspaceEnv.Value, machineName))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var folderName = Path.GetFileName(path);
|
var folderName = Path.GetFileName(path);
|
||||||
|
|
||||||
// Check we haven't returned '' if we have a path like C:\
|
// 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
|
public List<VSCodeWorkspace> Workspaces
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
Reference in New Issue
Block a user