diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-31 12:13:19 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 12:13:19 +0100 |
commit | 8c802a3dbb5ea1dea8de17f59d0620e3a710474a (patch) | |
tree | 33ae4c03f3e24f5ce0a77c818ab1e0e9ed02018d /editors/code/src | |
parent | 683d0a4d93c29c988c40c001a4b574d8f0dcb9c6 (diff) | |
parent | a85e64770d13598103c9122c6514ec3d5a3b0d53 (diff) |
Merge #5513
5513: Try figure out correct workspace in vscode multi root workspace r=vsrs a=urbandove
the code to replace the root with the `${workspaceRoot}` arg breaks in multi root workspaces as it needs a qualifier `${workspaceRoot:workspaceName}`
This PR attempts to figure out the root workspace - and if it cant find it falls back to the first workspace
Co-authored-by: Urban Dove <[email protected]>
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/debug.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index bd92c5b6d..925126a16 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts | |||
@@ -87,9 +87,17 @@ 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 | const isMultiFolderWorkspace = vscode.workspace.workspaceFolders!.length > 1; |
91 | const firstWorkspace = vscode.workspace.workspaceFolders![0]; // folder exists or RA is not active. | ||
92 | const workspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ? | ||
93 | firstWorkspace : | ||
94 | vscode.workspace.workspaceFolders!.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace; | ||
95 | |||
96 | const wsFolder = path.normalize(workspace.uri.fsPath); | ||
97 | const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : ''; | ||
91 | function simplifyPath(p: string): string { | 98 | function simplifyPath(p: string): string { |
92 | return path.normalize(p).replace(wsFolder, '${workspaceRoot}'); | 99 | // see https://github.com/rust-analyzer/rust-analyzer/pull/5513#issuecomment-663458818 for why this is needed |
100 | return path.normalize(p).replace(wsFolder, '${workspaceFolder' + workspaceQualifier + '}'); | ||
93 | } | 101 | } |
94 | 102 | ||
95 | const executable = await getDebugExecutable(runnable); | 103 | const executable = await getDebugExecutable(runnable); |