From ff55ca6ba7267b48c87e5801263d62d10b906f1f Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Thu, 26 Oct 2017 17:38:50 +0800 Subject: [PATCH] Fix variable reference bug in package.json for new vscode engine Signed-off-by: Jinbo Wang --- package.json | 6 +++--- src/debug/configurationProvider.ts | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index d527e97a..3a600b12 100644 --- a/package.json +++ b/package.json @@ -143,8 +143,8 @@ "name": "Arduino", "type": "arduino", "request": "launch", - "program": "$${{file}}", - "cwd": "$${{workspaceFolder}}", + "program": "^\"\\${file}\"", + "cwd": "^\"\\${workspaceFolder}\"", "MIMode": "gdb", "targetArchitecture": "arm", "miDebuggerPath": "", @@ -155,7 +155,7 @@ "text": "target remote localhost:3333" }, { - "text": "file $${{file}}" + "text": "^\"file \\${file}\"" }, { "text": "load" diff --git a/src/debug/configurationProvider.ts b/src/debug/configurationProvider.ts index 87cf4277..87dfbded 100644 --- a/src/debug/configurationProvider.ts +++ b/src/debug/configurationProvider.ts @@ -20,12 +20,27 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat public provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined, token?: vscode.CancellationToken): vscode.ProviderResult { - return [{ + return [ + this.getDefaultDebugSettings(folder), + ]; + } + + // Try to add all missing attributes to the debug configuration being launched. + public resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): + vscode.ProviderResult { + if (!config || !config.request) { + config = this.getDefaultDebugSettings(folder); + } + return this.resolveDebugConfigurationAsync(config); + } + + private getDefaultDebugSettings(folder: vscode.WorkspaceFolder | undefined) { + return { name: "Arduino", type: "arduino", request: "launch", program: "${file}", - cwd: folder, + cwd: "${workspaceFolder}", MIMode: "gdb", targetArchitecture: "arm", miDebuggerPath: "", @@ -53,16 +68,7 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat launchCompleteCommand: "exec-continue", filterStderr: true, args: [], - }]; - } - - // Try to add all missing attributes to the debug configuration being launched. - public resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): - vscode.ProviderResult { - if (config && !config.cwd) { - config.cwd = folder; - } - return this.resolveDebugConfigurationAsync(config); + }; } private async resolveDebugConfigurationAsync(config: vscode.DebugConfiguration) {