diff options
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 2635a1440..26db18156 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 { Cargo } from '../cargo'; | ||
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,25 +63,47 @@ export function runSingle(ctx: Ctx): Cmd { | |||
62 | }; | 63 | }; |
63 | } | 64 | } |
64 | 65 | ||
66 | function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { | ||
67 | return { | ||
68 | type: "lldb", | ||
69 | request: "launch", | ||
70 | name: config.label, | ||
71 | cargo: { | ||
72 | args: config.args, | ||
73 | }, | ||
74 | args: config.extraArgs, | ||
75 | cwd: config.cwd | ||
76 | }; | ||
77 | } | ||
78 | |||
79 | async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugConfiguration> { | ||
80 | let cargo = new Cargo(config.cwd || '.'); | ||
81 | let executable = await cargo.executableFromArgs(config.args, config.extraArgs); | ||
82 | |||
83 | return { | ||
84 | type: "cppvsdbg", | ||
85 | request: "launch", | ||
86 | name: config.label, | ||
87 | program: executable, | ||
88 | args: config.extraArgs, | ||
89 | cwd: config.cwd, | ||
90 | }; | ||
91 | } | ||
92 | |||
65 | export function debugSingle(ctx: Ctx): Cmd { | 93 | export function debugSingle(ctx: Ctx): Cmd { |
66 | return async (config: ra.Runnable) => { | 94 | return async (config: ra.Runnable) => { |
67 | const editor = ctx.activeRustEditor; | 95 | const editor = ctx.activeRustEditor; |
68 | if (!editor) return; | 96 | if (!editor) return; |
69 | if (!vscode.extensions.getExtension("vadimcn.vscode-lldb")) { | 97 | |
70 | vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` extension for debugging"); | 98 | const mscpp = vscode.extensions.getExtension("ms-vscode.cpptools"); |
99 | const lldb = vscode.extensions.getExtension("vadimcn.vscode-lldb"); | ||
100 | |||
101 | if (!(lldb || mscpp)) { | ||
102 | vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` or `ms-vscode.cpptools` extension for debugging"); | ||
71 | return; | 103 | return; |
72 | } | 104 | } |
73 | 105 | ||
74 | const debugConfig = { | 106 | const debugConfig = lldb ? getLldbDebugConfig(config) : await getCppvsDebugConfig(config); |
75 | type: "lldb", | ||
76 | request: "launch", | ||
77 | name: config.label, | ||
78 | cargo: { | ||
79 | args: config.args, | ||
80 | }, | ||
81 | args: config.extraArgs, | ||
82 | cwd: config.cwd | ||
83 | }; | ||
84 | 107 | ||
85 | return vscode.debug.startDebugging(undefined, debugConfig); | 108 | return vscode.debug.startDebugging(undefined, debugConfig); |
86 | }; | 109 | }; |