diff options
| author | vsrs <vit@conrlab.com> | 2020-04-29 13:10:42 +0300 |
|---|---|---|
| committer | vsrs <vit@conrlab.com> | 2020-04-29 13:10:42 +0300 |
| commit | 042917e6e3bc3cb05e08e487ee8a7d0d4ae3af6b (patch) | |
| tree | a6decd4bf82f575d39e13fccdbae626f70850e9e /editors/code/src | |
| parent | 48d6e828f1878436bb8633a1e7df02a6383d991a (diff) | |
| download | rust-042917e6e3bc3cb05e08e487ee8a7d0d4ae3af6b.tar.gz rust-042917e6e3bc3cb05e08e487ee8a7d0d4ae3af6b.zip | |
Configuration settings and source maps support
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/cargo.ts | 1 | ||||
| -rw-r--r-- | editors/code/src/commands/runnables.ts | 33 | ||||
| -rw-r--r-- | editors/code/src/config.ts | 9 |
3 files changed, 33 insertions, 10 deletions
diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts index d119b62253f..5999187f4b8 100644 --- a/editors/code/src/cargo.ts +++ b/editors/code/src/cargo.ts @@ -1,4 +1,3 @@ -import { window } from 'vscode'; import * as cp from 'child_process'; import * as readline from 'readline'; diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 26db18156f5..befb8b3663f 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 { }; } -function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { +function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): vscode.DebugConfiguration { return { type: "lldb", request: "launch", @@ -72,11 +72,12 @@ function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { args: config.args, }, args: config.extraArgs, - cwd: config.cwd + cwd: config.cwd, + sourceMap: sourceFileMap }; } -async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugConfiguration> { +async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> { let cargo = new Cargo(config.cwd || '.'); let executable = await cargo.executableFromArgs(config.args, config.extraArgs); @@ -87,6 +88,7 @@ async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugCo program: executable, args: config.extraArgs, cwd: config.cwd, + sourceFileMap: sourceFileMap, }; } @@ -95,15 +97,30 @@ export function debugSingle(ctx: Ctx): Cmd { const editor = ctx.activeRustEditor; if (!editor) return; - const mscpp = vscode.extensions.getExtension("ms-vscode.cpptools"); - const lldb = vscode.extensions.getExtension("vadimcn.vscode-lldb"); + const lldbId = "vadimcn.vscode-lldb"; + const cpptoolsId = "ms-vscode.cpptools"; + + let debugEngineId = ctx.config.debug.engine; + let debugEngine = null; + if (!debugEngineId) { + debugEngine = vscode.extensions.getExtension(lldbId); + if (!debugEngine) { + debugEngine = vscode.extensions.getExtension(cpptoolsId); + } + } + else { + debugEngine = vscode.extensions.getExtension(debugEngineId); + } - if (!(lldb || mscpp)) { - vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` or `ms-vscode.cpptools` extension for debugging"); + if (!debugEngine) { + vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=${lldbId})` + + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`); return; } - const debugConfig = lldb ? getLldbDebugConfig(config) : await getCppvsDebugConfig(config); + const debugConfig = lldbId == debugEngine.id + ? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap) + : await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap); return vscode.debug.startDebugging(undefined, debugConfig); }; diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 3b2eec8baa7..7764a217943 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -92,7 +92,6 @@ export class Config { get askBeforeDownload() { return this.get<boolean>("updates.askBeforeDownload"); } get traceExtension() { return this.get<boolean>("trace.extension"); } - get inlayHints() { return { typeHints: this.get<boolean>("inlayHints.typeHints"), @@ -107,4 +106,12 @@ export class Config { command: this.get<string>("checkOnSave.command"), }; } + + get debug() { + return { + engine: this.get<null | string>("debug.engine"), + sourceFileMap: this.get<Record<string, string>>("debug.sourceFileMap"), + }; + } + } |
