Skip to content

Commit b325286

Browse files
committed
try select correct workspace in vscode multi workspace
1 parent 6ddcdb8 commit b325286

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

editors/code/src/debug.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,18 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
8787
debugOutput.show(true);
8888
}
8989

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}` : '';
9199
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 + '}');
93102
}
94103

95104
const executable = await getDebugExecutable(runnable);

0 commit comments

Comments
 (0)