aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands
diff options
context:
space:
mode:
authorHannes De Valkeneer <[email protected]>2020-03-09 21:06:45 +0000
committerHannes De Valkeneer <[email protected]>2020-03-11 21:26:47 +0000
commite903fd0d9726dc6343a26ddeb919099fb8e4979e (patch)
tree23c2de00603542c434cc8e413c7d7cc425869cd2 /editors/code/src/commands
parent05b4fc6d79060fc3120f92b01119e3a851c37829 (diff)
feat: add debug code lens
Refs #3539
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r--editors/code/src/commands/runnables.ts28
1 files changed, 27 insertions, 1 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 06b513466..faa92799c 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -3,6 +3,7 @@ import * as lc from 'vscode-languageclient';
3import * as ra from '../rust-analyzer-api'; 3import * as ra from '../rust-analyzer-api';
4 4
5import { Ctx, Cmd } from '../ctx'; 5import { Ctx, Cmd } from '../ctx';
6import { debug } from 'vscode';
6 7
7export function run(ctx: Ctx): Cmd { 8export function run(ctx: Ctx): Cmd {
8 let prevRunnable: RunnableQuickPick | undefined; 9 let prevRunnable: RunnableQuickPick | undefined;
@@ -62,6 +63,31 @@ export function runSingle(ctx: Ctx): Cmd {
62 }; 63 };
63} 64}
64 65
66export function debugSingle(ctx: Ctx): Cmd {
67 return async (config: ra.Runnable) => {
68 const editor = ctx.activeRustEditor;
69 if (!editor) return;
70
71 if (config.args[0] === 'run') {
72 config.args[0] = 'build';
73 } else {
74 config.args.push('--no-run');
75 }
76
77 const debugConfig = {
78 type: "lldb",
79 request: "launch",
80 name: config.label,
81 cargo: {
82 args: config.args,
83 },
84 args: config.extraArgs,
85 cwd: config.cwd
86 };
87 return debug.startDebugging(undefined, debugConfig);
88 };
89}
90
65class RunnableQuickPick implements vscode.QuickPickItem { 91class RunnableQuickPick implements vscode.QuickPickItem {
66 public label: string; 92 public label: string;
67 public description?: string | undefined; 93 public description?: string | undefined;
@@ -87,7 +113,7 @@ function createTask(spec: ra.Runnable): vscode.Task {
87 type: 'cargo', 113 type: 'cargo',
88 label: spec.label, 114 label: spec.label,
89 command: spec.bin, 115 command: spec.bin,
90 args: spec.args, 116 args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args,
91 env: spec.env, 117 env: spec.env,
92 }; 118 };
93 119