Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit 79a6b01

Browse files
hyangahramya-rao-a
andauthored
Fix 'run without debugging' when using modules or no user debug configuration (#3125)
* 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 #3121 TESTED=manually with the example attached in #3121 * Handle case when debugConfiguration doesnt exist Co-authored-by: Ramya Achutha Rao <[email protected]>
1 parent 28bab92 commit 79a6b01

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/debugAdapter/goDebug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ class Delve {
435435
runOptions.cwd = program;
436436
runArgs.push('.');
437437
} else {
438+
runOptions.cwd = dirname;
438439
runArgs.push(program);
439440
}
440441
if (launchArgs.args) {

src/goDebugConfiguration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
4747
return;
4848
}
4949

50-
debugConfiguration = {
50+
debugConfiguration = Object.assign(debugConfiguration || {}, {
5151
name: 'Launch',
5252
type: 'go',
5353
request: 'launch',
5454
mode: 'auto',
5555
program: activeEditor.document.fileName
56-
};
56+
});
5757
}
5858

5959
debugConfiguration['packagePathToGoModPathMap'] = packagePathToGoModPathMap;

0 commit comments

Comments
 (0)