Skip to content

Commit

Permalink
microsoft#16283 VS Code Workspaces not showing up after update or fir…
Browse files Browse the repository at this point in the history
…st installation
  • Loading branch information
ricardosantos9521 committed Mar 26, 2022
1 parent ba73bc7 commit 89cbef1
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
{
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");

Expand Down Expand Up @@ -62,13 +62,19 @@ public static Bitmap BitmapOverlayToCenter(Bitmap bitmap1, Bitmap overlayBitmap)
// Gets the executablePath and AppData foreach instance of VSCode
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>();

_systemPath = Environment.GetEnvironmentVariable("PATH");
var paths = _systemPath.Split(";");
paths = paths.Where(x => x.Contains("VS Code") || x.Contains("VSCodium")).ToArray();
paths = paths.Where(x => x.Contains("VS Code") || x.Contains("VSCodium")).ToList();
foreach (var path in paths)
{
if (Directory.Exists(path))
Expand Down

0 comments on commit 89cbef1

Please sign in to comment.