From 889770db3dbdf1e73279331c65ad5cac34f04e99 Mon Sep 17 00:00:00 2001 From: "Hana (Hyang-Ah) Kim" Date: Tue, 24 Mar 2020 16:34:12 -0400 Subject: [PATCH 1/2] debug: fix 'run without debugging' Bug 1: when generating the default debug configuration because there is no user-configured one, the extension dropped noDebug field and caused the program to run with debugging enabled. Fix it (goDebugConfiguration.ts) Bug 2: when debug adapter receives noDebug request, it runs the program with `go run` instead of invoking the program through dlv. The `go run` will not work in modules mode if the command runs outside the main module. Set cwd accordingly. Fixes microsoft/vscode-go#3121 TESTED=manually with the example attached in #3121 --- src/debugAdapter/goDebug.ts | 1 + src/goDebugConfiguration.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index a9a309ef4..98bdbd0d4 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -435,6 +435,7 @@ class Delve { runOptions.cwd = program; runArgs.push('.'); } else { + runOptions.cwd = dirname; runArgs.push(program); } if (launchArgs.args) { diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts index 367fd2815..dd0050495 100644 --- a/src/goDebugConfiguration.ts +++ b/src/goDebugConfiguration.ts @@ -47,13 +47,13 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr return; } - debugConfiguration = { + debugConfiguration = Object.assign(debugConfiguration, { name: 'Launch', type: 'go', request: 'launch', mode: 'auto', program: activeEditor.document.fileName - }; + }); } debugConfiguration['packagePathToGoModPathMap'] = packagePathToGoModPathMap; From f678ef4fce502818ce3aa9b6933be931de170271 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Tue, 24 Mar 2020 23:24:54 -0700 Subject: [PATCH 2/2] Handle case when debugConfiguration doesnt exist --- src/goDebugConfiguration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts index dd0050495..f9fe07cbc 100644 --- a/src/goDebugConfiguration.ts +++ b/src/goDebugConfiguration.ts @@ -47,7 +47,7 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr return; } - debugConfiguration = Object.assign(debugConfiguration, { + debugConfiguration = Object.assign(debugConfiguration || {}, { name: 'Launch', type: 'go', request: 'launch',