From 65f457e9d1c9bcc59d2227e1b81e721e1440da70 Mon Sep 17 00:00:00 2001
From: Bruno Meneguello <1322552+bkmeneguello@users.noreply.github.com>
Date: Mon, 1 Aug 2022 13:03:50 -0300
Subject: [PATCH] [PT Run][VSCodeWorkspace] Adds support for VSCode portable
(#19442)
* [PT Run][VSCodeWorkspace] Adds support for VSCode portable
* Add PATH warning to the subheader
---
.../Properties/Resources.resx | 3 ++-
.../VSCodeHelper/VSCodeInstances.cs | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
index a155262872..ca9d176229 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Properties/Resources.resx
@@ -125,7 +125,8 @@
Used to indicate the location where something is
- Opens workspaces, remote machines (SSH or Codespaces) and containers, previously opened in VS Code.
+ Opens workspaces, remote machines (SSH or Codespaces) and containers, previously opened in VS Code. The VS Code instance needs to be in PATH.
+ VS Code is the name of a product. PATH is the name of an environment variable. Don't translate it.
SSH remote machine
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs
index 21518700b8..b4172d5a50 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs
@@ -122,7 +122,9 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
if (version != string.Empty)
{
- instance.AppData = Path.Combine(_userAppDataPath, version);
+ 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");
var bitmapIconVscode = Icon.ExtractAssociatedIcon(iconVSCode).ToBitmap();