about summary refs log tree commit diff
path: root/editors/code/src/debug.ts
diff options
context:
space:
mode:
authorUrban Dove <urbandove80@gmail.com>2020-07-25 22:16:35 -0400
committerUrban Dove <urbandove80@gmail.com>2020-07-25 22:23:13 -0400
commitb32528659a64f74da4b652c44b9fb47844899809 (patch)
tree06e0de9653196ec87311eb9f40a83c7eeb1ae5a7 /editors/code/src/debug.ts
parent6ddcdb8b29f495f09b9e2456001be252d401e394 (diff)
downloadrust-b32528659a64f74da4b652c44b9fb47844899809.tar.gz
rust-b32528659a64f74da4b652c44b9fb47844899809.zip
try select correct workspace in vscode multi workspace
Diffstat (limited to 'editors/code/src/debug.ts')
-rw-r--r--editors/code/src/debug.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts
index bd92c5b6d73..1427ecf9ac7 100644
--- a/editors/code/src/debug.ts
+++ b/editors/code/src/debug.ts
@@ -87,9 +87,18 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
         debugOutput.show(true);
     }
 
-    const wsFolder = path.normalize(vscode.workspace.workspaceFolders![0].uri.fsPath); // folder exists or RA is not active.
+
+    const isMultiFolderWorkspace = vscode.workspace.workspaceFolders!.length > 1;
+    const firstWorkspace = vscode.workspace.workspaceFolders![0]; // folder exists or RA is not active.
+    const workspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ?
+        firstWorkspace :
+        vscode.workspace.workspaceFolders!.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace;
+
+    const wsFolder = path.normalize(workspace.uri.fsPath);
+    const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : '';
     function simplifyPath(p: string): string {
-        return path.normalize(p).replace(wsFolder, '${workspaceRoot}');
+        // see https://github.com/rust-analyzer/rust-analyzer/pull/5513#issuecomment-663458818 for why this is needed
+        return path.normalize(p).replace(wsFolder, '${workspaceFolder' + workspaceQualifier + '}');
     }
 
     const executable = await getDebugExecutable(runnable);