diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index bd92c5b6d73..925126a16ff 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 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);