diff options
author | Urban Dove <[email protected]> | 2020-07-26 03:16:35 +0100 |
---|---|---|
committer | Urban Dove <[email protected]> | 2020-07-26 03:23:13 +0100 |
commit | b32528659a64f74da4b652c44b9fb47844899809 (patch) | |
tree | 06e0de9653196ec87311eb9f40a83c7eeb1ae5a7 /editors/code/src | |
parent | 6ddcdb8b29f495f09b9e2456001be252d401e394 (diff) |
try select correct workspace in vscode multi workspace
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/debug.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index bd92c5b6d..1427ecf9a 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 | |||
87 | debugOutput.show(true); | 87 | debugOutput.show(true); |
88 | } | 88 | } |
89 | 89 | ||
90 | const wsFolder = path.normalize(vscode.workspace.workspaceFolders![0].uri.fsPath); // folder exists or RA is not active. | 90 | |
91 | const isMultiFolderWorkspace = vscode.workspace.workspaceFolders!.length > 1; | ||
92 | const firstWorkspace = vscode.workspace.workspaceFolders![0]; // folder exists or RA is not active. | ||
93 | const workspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ? | ||
94 | firstWorkspace : | ||
95 | vscode.workspace.workspaceFolders!.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace; | ||
96 | |||
97 | const wsFolder = path.normalize(workspace.uri.fsPath); | ||
98 | const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : ''; | ||
91 | function simplifyPath(p: string): string { | 99 | function simplifyPath(p: string): string { |
92 | return path.normalize(p).replace(wsFolder, '${workspaceRoot}'); | 100 | // see https://github.com/rust-analyzer/rust-analyzer/pull/5513#issuecomment-663458818 for why this is needed |
101 | return path.normalize(p).replace(wsFolder, '${workspaceFolder' + workspaceQualifier + '}'); | ||
93 | } | 102 | } |
94 | 103 | ||
95 | const executable = await getDebugExecutable(runnable); | 104 | const executable = await getDebugExecutable(runnable); |