diff options
-rw-r--r-- | editors/code/package.json | 5 | ||||
-rw-r--r-- | editors/code/src/config.ts | 1 | ||||
-rw-r--r-- | editors/code/src/debug.ts | 21 |
3 files changed, 25 insertions, 2 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index ec325ad3f..34dbea0b2 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -443,6 +443,11 @@ | |||
443 | "type": "object", | 443 | "type": "object", |
444 | "default": {}, | 444 | "default": {}, |
445 | "description": "Optional settings passed to the debug engine. Example:\n{ \"lldb\": { \"terminal\":\"external\"} }" | 445 | "description": "Optional settings passed to the debug engine. Example:\n{ \"lldb\": { \"terminal\":\"external\"} }" |
446 | }, | ||
447 | "rust-analyzer.debug.useLaunchJson": { | ||
448 | "description": "Whether to use existing configurations from launch.json.", | ||
449 | "type": "boolean", | ||
450 | "default": false | ||
446 | } | 451 | } |
447 | } | 452 | } |
448 | }, | 453 | }, |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index be2e27aec..24002483d 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -117,6 +117,7 @@ export class Config { | |||
117 | engineSettings: this.get<object>("debug.engineSettings"), | 117 | engineSettings: this.get<object>("debug.engineSettings"), |
118 | openUpDebugPane: this.get<boolean>("debug.openUpDebugPane"), | 118 | openUpDebugPane: this.get<boolean>("debug.openUpDebugPane"), |
119 | sourceFileMap: sourceFileMap, | 119 | sourceFileMap: sourceFileMap, |
120 | useLaunchJson: this.get<object>("debug.useLaunchJson"), | ||
120 | }; | 121 | }; |
121 | } | 122 | } |
122 | } | 123 | } |
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index cc5755611..bbf3ff312 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts | |||
@@ -95,10 +95,27 @@ export async function getDebugConfiguration(ctx: Ctx, config: ra.Runnable): Prom | |||
95 | } | 95 | } |
96 | 96 | ||
97 | export async function startDebugSession(ctx: Ctx, config: ra.Runnable): Promise<boolean> { | 97 | export async function startDebugSession(ctx: Ctx, config: ra.Runnable): Promise<boolean> { |
98 | const debugConfig = await getDebugConfiguration(ctx, config); | 98 | let debugConfig: vscode.DebugConfiguration | undefined = undefined; |
99 | let message = ""; | ||
100 | |||
101 | if (ctx.config.debug.useLaunchJson) { | ||
102 | const wsLaunchSection = vscode.workspace.getConfiguration("launch"); | ||
103 | const configurations = wsLaunchSection.get<any[]>("configurations") || []; | ||
104 | |||
105 | const index = configurations.findIndex(c => c.name === config.label); | ||
106 | if (-1 !== index) { | ||
107 | debugConfig = configurations[index]; | ||
108 | message = " (from launch.json)"; | ||
109 | debugOutput.clear(); | ||
110 | } | ||
111 | } | ||
112 | if (!debugConfig) { | ||
113 | debugConfig = await getDebugConfiguration(ctx, config); | ||
114 | } | ||
115 | |||
99 | if (!debugConfig) return false; | 116 | if (!debugConfig) return false; |
100 | 117 | ||
101 | debugOutput.appendLine("Launching debug configuration:"); | 118 | debugOutput.appendLine(`Launching debug configuration${message}:`); |
102 | debugOutput.appendLine(JSON.stringify(debugConfig, null, 2)); | 119 | debugOutput.appendLine(JSON.stringify(debugConfig, null, 2)); |
103 | return vscode.debug.startDebugging(undefined, debugConfig); | 120 | return vscode.debug.startDebugging(undefined, debugConfig); |
104 | } | 121 | } |