feat: add debug code lens

Refs #3539
This commit is contained in:
Hannes De Valkeneer 2020-03-09 22:06:45 +01:00
parent 05b4fc6d79
commit e903fd0d97
8 changed files with 77 additions and 30 deletions

View file

@ -3,6 +3,7 @@ import * as lc from 'vscode-languageclient';
import * as ra from '../rust-analyzer-api';
import { Ctx, Cmd } from '../ctx';
import { debug } from 'vscode';
export function run(ctx: Ctx): Cmd {
let prevRunnable: RunnableQuickPick | undefined;
@ -62,6 +63,31 @@ export function runSingle(ctx: Ctx): Cmd {
};
}
export function debugSingle(ctx: Ctx): Cmd {
return async (config: ra.Runnable) => {
const editor = ctx.activeRustEditor;
if (!editor) return;
if (config.args[0] === 'run') {
config.args[0] = 'build';
} else {
config.args.push('--no-run');
}
const debugConfig = {
type: "lldb",
request: "launch",
name: config.label,
cargo: {
args: config.args,
},
args: config.extraArgs,
cwd: config.cwd
};
return debug.startDebugging(undefined, debugConfig);
};
}
class RunnableQuickPick implements vscode.QuickPickItem {
public label: string;
public description?: string | undefined;
@ -87,7 +113,7 @@ function createTask(spec: ra.Runnable): vscode.Task {
type: 'cargo',
label: spec.label,
command: spec.bin,
args: spec.args,
args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args,
env: spec.env,
};