Skip to content

Commit

Permalink
debug: fix 'run without debugging'
Browse files Browse the repository at this point in the history
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#3121

TESTED=manually with the example attached in microsoft#3121
  • Loading branch information
hyangah committed Mar 24, 2020
1 parent 28bab92 commit 889770d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ class Delve {
runOptions.cwd = program;
runArgs.push('.');
} else {
runOptions.cwd = dirname;
runArgs.push(program);
}
if (launchArgs.args) {
Expand Down
4 changes: 2 additions & 2 deletions src/goDebugConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 889770d

Please sign in to comment.