Skip to content

Commit

Permalink
Merge pull request #15 from MaskedRPGFan/portable_instances_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
taooceros authored Aug 19, 2024
2 parents 6515058 + 809ea5b commit e4ef340
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
25 changes: 16 additions & 9 deletions VSCodeHelper/VSCodeInstances.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public static void LoadVSCodeInstances()
{
if (_systemPath == Environment.GetEnvironmentVariable("PATH"))
return;


Instances = new List<VSCodeInstance>();

_systemPath = Environment.GetEnvironmentVariable("PATH") ?? "";
Expand All @@ -77,17 +77,24 @@ public static void LoadVSCodeInstances()
{
if (!Directory.Exists(path))
continue;

var files = Directory.EnumerateFiles(path).Where(x =>

var newPath = path;
if (!Path.GetFileName(path).Equals("bin", StringComparison.OrdinalIgnoreCase))
newPath = Path.Combine(path, "bin");

if (!Directory.Exists(newPath))
continue;

var files = Directory.EnumerateFiles(newPath).Where(x =>
(x.Contains("code", StringComparison.OrdinalIgnoreCase) ||
x.Contains("codium", StringComparison.OrdinalIgnoreCase))
&& !x.EndsWith(".cmd", StringComparison.OrdinalIgnoreCase)).ToArray();

var iconPath = Path.GetDirectoryName(path);
var iconPath = Path.GetDirectoryName(newPath);

if (files.Length <= 0)
continue;

var file = files[0];
var version = string.Empty;

Expand Down Expand Up @@ -119,8 +126,8 @@ public static void LoadVSCodeInstances()

if (version == string.Empty)
continue;


var portableData = Path.Join(iconPath, "data");
instance.AppData = Directory.Exists(portableData) ? Path.Join(portableData, "user-data") : Path.Combine(_userAppDataPath, version);
var iconVSCode = Path.Join(iconPath, $"{version}.exe");
Expand All @@ -140,4 +147,4 @@ public static void LoadVSCodeInstances()
}
}
}
}
}
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"Decription": "Opens workspaces, remote machines (SSH or Codespaces) and containers, previously opened in VS Code.",
"ActionKeyword": "{",
"Name": "VS Code Workspaces",
"Author": "ricardosantos9521",
"Version": "1.3.1",
"Author": "ricardosantos9521, MaskedRPGFan",
"Version": "1.3.2",
"Language": "csharp",
"Website": "https://github.com/taooceros/Flow.Plugin.VSCodeWorkspace",
"ExecuteFileName": "Flow.Plugin.VSCodeWorkspaces.dll",
Expand Down

0 comments on commit e4ef340

Please sign in to comment.