mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Use launch.json in Debug Lens sessions.
Add the possibility to use existing configurations via Debug Lens
This commit is contained in:
parent
e914d622ec
commit
9ebb2acdca
3 changed files with 25 additions and 2 deletions
|
@ -443,6 +443,11 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"default": {},
|
"default": {},
|
||||||
"description": "Optional settings passed to the debug engine. Example:\n{ \"lldb\": { \"terminal\":\"external\"} }"
|
"description": "Optional settings passed to the debug engine. Example:\n{ \"lldb\": { \"terminal\":\"external\"} }"
|
||||||
|
},
|
||||||
|
"rust-analyzer.debug.useLaunchJson": {
|
||||||
|
"description": "Whether to use existing configurations from launch.json.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -117,6 +117,7 @@ export class Config {
|
||||||
engineSettings: this.get<object>("debug.engineSettings"),
|
engineSettings: this.get<object>("debug.engineSettings"),
|
||||||
openUpDebugPane: this.get<boolean>("debug.openUpDebugPane"),
|
openUpDebugPane: this.get<boolean>("debug.openUpDebugPane"),
|
||||||
sourceFileMap: sourceFileMap,
|
sourceFileMap: sourceFileMap,
|
||||||
|
useLaunchJson: this.get<object>("debug.useLaunchJson"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,10 +95,27 @@ export async function getDebugConfiguration(ctx: Ctx, config: ra.Runnable): Prom
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startDebugSession(ctx: Ctx, config: ra.Runnable): Promise<boolean> {
|
export async function startDebugSession(ctx: Ctx, config: ra.Runnable): Promise<boolean> {
|
||||||
const debugConfig = await getDebugConfiguration(ctx, config);
|
let debugConfig: vscode.DebugConfiguration | undefined = undefined;
|
||||||
|
let message = "";
|
||||||
|
|
||||||
|
if (ctx.config.debug.useLaunchJson) {
|
||||||
|
const wsLaunchSection = vscode.workspace.getConfiguration("launch");
|
||||||
|
const configurations = wsLaunchSection.get<any[]>("configurations") || [];
|
||||||
|
|
||||||
|
const index = configurations.findIndex(c => c.name === config.label);
|
||||||
|
if (-1 !== index) {
|
||||||
|
debugConfig = configurations[index];
|
||||||
|
message = " (from launch.json)";
|
||||||
|
debugOutput.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!debugConfig) {
|
||||||
|
debugConfig = await getDebugConfiguration(ctx, config);
|
||||||
|
}
|
||||||
|
|
||||||
if (!debugConfig) return false;
|
if (!debugConfig) return false;
|
||||||
|
|
||||||
debugOutput.appendLine("Launching debug configuration:");
|
debugOutput.appendLine(`Launching debug configuration${message}:`);
|
||||||
debugOutput.appendLine(JSON.stringify(debugConfig, null, 2));
|
debugOutput.appendLine(JSON.stringify(debugConfig, null, 2));
|
||||||
return vscode.debug.startDebugging(undefined, debugConfig);
|
return vscode.debug.startDebugging(undefined, debugConfig);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue