From e903fd0d9726dc6343a26ddeb919099fb8e4979e Mon Sep 17 00:00:00 2001 From: Hannes De Valkeneer Date: Mon, 9 Mar 2020 22:06:45 +0100 Subject: feat: add debug code lens Refs #3539 --- editors/code/src/commands/runnables.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'editors/code/src/commands/runnables.ts') 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'; 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, }; -- cgit v1.2.3 From a034257e5ed5a3758e1ea2f72b3b905d1b2b320a Mon Sep 17 00:00:00 2001 From: Hannes De Valkeneer Date: Thu, 12 Mar 2020 21:00:40 +0100 Subject: fixup! feat: add debug code lens --- editors/code/src/commands/runnables.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'editors/code/src/commands/runnables.ts') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index faa92799c..51cfb37d5 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -3,7 +3,6 @@ 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; @@ -84,7 +83,7 @@ export function debugSingle(ctx: Ctx): Cmd { args: config.extraArgs, cwd: config.cwd }; - return debug.startDebugging(undefined, debugConfig); + return vscode.debug.startDebugging(undefined, debugConfig); }; } -- cgit v1.2.3 From e9d025b618aaa1a5a06e60c17392a18f12471217 Mon Sep 17 00:00:00 2001 From: Hannes De Valkeneer Date: Thu, 12 Mar 2020 21:28:26 +0100 Subject: fixup! feat: add debug code lens avoid repetition of `--no-run` --- editors/code/src/commands/runnables.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'editors/code/src/commands/runnables.ts') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 51cfb37d5..357155163 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -67,12 +67,6 @@ export function debugSingle(ctx: Ctx): Cmd { 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", @@ -83,6 +77,7 @@ export function debugSingle(ctx: Ctx): Cmd { args: config.extraArgs, cwd: config.cwd }; + return vscode.debug.startDebugging(undefined, debugConfig); }; } -- cgit v1.2.3