mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[PTRun][VSCode] Workspaces not showing up after update or first installation (#17279)
This commit is contained in:
committed by
GitHub
parent
686a48a29b
commit
44165621f0
@@ -15,7 +15,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
|
|||||||
{
|
{
|
||||||
public static class VSCodeInstances
|
public static class VSCodeInstances
|
||||||
{
|
{
|
||||||
private static string _systemPath = string.Empty;
|
private static List<string> _paths = new List<string>();
|
||||||
|
|
||||||
private static string _userAppDataPath = Environment.GetEnvironmentVariable("AppData");
|
private static string _userAppDataPath = Environment.GetEnvironmentVariable("AppData");
|
||||||
|
|
||||||
@@ -62,13 +62,19 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
|
|||||||
// Gets the executablePath and AppData foreach instance of VSCode
|
// Gets the executablePath and AppData foreach instance of VSCode
|
||||||
public static void LoadVSCodeInstances()
|
public static void LoadVSCodeInstances()
|
||||||
{
|
{
|
||||||
if (_systemPath != Environment.GetEnvironmentVariable("PATH"))
|
var environmentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User);
|
||||||
|
environmentPath += (environmentPath.Length > 0 && environmentPath.EndsWith(';') ? ";" : string.Empty) + Environment.GetEnvironmentVariable("PATH");
|
||||||
|
var paths = environmentPath.Split(";").ToList();
|
||||||
|
paths = paths.Distinct().ToList();
|
||||||
|
|
||||||
|
var deletedItems = paths.Except(_paths).Any();
|
||||||
|
var newItems = _paths.Except(paths).Any();
|
||||||
|
|
||||||
|
if (newItems || deletedItems)
|
||||||
{
|
{
|
||||||
Instances = new List<VSCodeInstance>();
|
Instances = new List<VSCodeInstance>();
|
||||||
|
|
||||||
_systemPath = Environment.GetEnvironmentVariable("PATH");
|
paths = paths.Where(x => x.Contains("VS Code") || x.Contains("VSCodium")).ToList();
|
||||||
var paths = _systemPath.Split(";");
|
|
||||||
paths = paths.Where(x => x.Contains("VS Code") || x.Contains("VSCodium")).ToArray();
|
|
||||||
foreach (var path in paths)
|
foreach (var path in paths)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(path))
|
if (Directory.Exists(path))
|
||||||
|
|||||||
Reference in New Issue
Block a user