diff options
author | vsrs <[email protected]> | 2020-04-29 11:10:42 +0100 |
---|---|---|
committer | vsrs <[email protected]> | 2020-04-29 11:10:42 +0100 |
commit | 042917e6e3bc3cb05e08e487ee8a7d0d4ae3af6b (patch) | |
tree | a6decd4bf82f575d39e13fccdbae626f70850e9e /editors/code/src/commands/runnables.ts | |
parent | 48d6e828f1878436bb8633a1e7df02a6383d991a (diff) |
Configuration settings and source maps support
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 26db18156..befb8b366 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
@@ -63,7 +63,7 @@ export function runSingle(ctx: Ctx): Cmd { | |||
63 | }; | 63 | }; |
64 | } | 64 | } |
65 | 65 | ||
66 | function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { | 66 | function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): vscode.DebugConfiguration { |
67 | return { | 67 | return { |
68 | type: "lldb", | 68 | type: "lldb", |
69 | request: "launch", | 69 | request: "launch", |
@@ -72,11 +72,12 @@ function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { | |||
72 | args: config.args, | 72 | args: config.args, |
73 | }, | 73 | }, |
74 | args: config.extraArgs, | 74 | args: config.extraArgs, |
75 | cwd: config.cwd | 75 | cwd: config.cwd, |
76 | sourceMap: sourceFileMap | ||
76 | }; | 77 | }; |
77 | } | 78 | } |
78 | 79 | ||
79 | async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugConfiguration> { | 80 | async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> { |
80 | let cargo = new Cargo(config.cwd || '.'); | 81 | let cargo = new Cargo(config.cwd || '.'); |
81 | let executable = await cargo.executableFromArgs(config.args, config.extraArgs); | 82 | let executable = await cargo.executableFromArgs(config.args, config.extraArgs); |
82 | 83 | ||
@@ -87,6 +88,7 @@ async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugCo | |||
87 | program: executable, | 88 | program: executable, |
88 | args: config.extraArgs, | 89 | args: config.extraArgs, |
89 | cwd: config.cwd, | 90 | cwd: config.cwd, |
91 | sourceFileMap: sourceFileMap, | ||
90 | }; | 92 | }; |
91 | } | 93 | } |
92 | 94 | ||
@@ -95,15 +97,30 @@ export function debugSingle(ctx: Ctx): Cmd { | |||
95 | const editor = ctx.activeRustEditor; | 97 | const editor = ctx.activeRustEditor; |
96 | if (!editor) return; | 98 | if (!editor) return; |
97 | 99 | ||
98 | const mscpp = vscode.extensions.getExtension("ms-vscode.cpptools"); | 100 | const lldbId = "vadimcn.vscode-lldb"; |
99 | const lldb = vscode.extensions.getExtension("vadimcn.vscode-lldb"); | 101 | const cpptoolsId = "ms-vscode.cpptools"; |
102 | |||
103 | let debugEngineId = ctx.config.debug.engine; | ||
104 | let debugEngine = null; | ||
105 | if (!debugEngineId) { | ||
106 | debugEngine = vscode.extensions.getExtension(lldbId); | ||
107 | if (!debugEngine) { | ||
108 | debugEngine = vscode.extensions.getExtension(cpptoolsId); | ||
109 | } | ||
110 | } | ||
111 | else { | ||
112 | debugEngine = vscode.extensions.getExtension(debugEngineId); | ||
113 | } | ||
100 | 114 | ||
101 | if (!(lldb || mscpp)) { | 115 | if (!debugEngine) { |
102 | vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` or `ms-vscode.cpptools` extension for debugging"); | 116 | vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=${lldbId})` |
117 | + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`); | ||
103 | return; | 118 | return; |
104 | } | 119 | } |
105 | 120 | ||
106 | const debugConfig = lldb ? getLldbDebugConfig(config) : await getCppvsDebugConfig(config); | 121 | const debugConfig = lldbId == debugEngine.id |
122 | ? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap) | ||
123 | : await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap); | ||
107 | 124 | ||
108 | return vscode.debug.startDebugging(undefined, debugConfig); | 125 | return vscode.debug.startDebugging(undefined, debugConfig); |
109 | }; | 126 | }; |