diff options
author | Hannes De Valkeneer <[email protected]> | 2020-03-09 21:06:45 +0000 |
---|---|---|
committer | Hannes De Valkeneer <[email protected]> | 2020-03-11 21:26:47 +0000 |
commit | e903fd0d9726dc6343a26ddeb919099fb8e4979e (patch) | |
tree | 23c2de00603542c434cc8e413c7d7cc425869cd2 /editors/code/src/commands | |
parent | 05b4fc6d79060fc3120f92b01119e3a851c37829 (diff) |
feat: add debug code lens
Refs #3539
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 28 |
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'; | |||
3 | import * as ra from '../rust-analyzer-api'; | 3 | import * as ra from '../rust-analyzer-api'; |
4 | 4 | ||
5 | import { Ctx, Cmd } from '../ctx'; | 5 | import { Ctx, Cmd } from '../ctx'; |
6 | import { debug } from 'vscode'; | ||
6 | 7 | ||
7 | export function run(ctx: Ctx): Cmd { | 8 | export 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 | ||
66 | export 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 | |||
65 | class RunnableQuickPick implements vscode.QuickPickItem { | 91 | class 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 | ||