Skip to content

Commit 44b7d36

Browse files
committed
src/goDebugConfiguration: clean up launch config snippets
Merged the package debug/test configuration snippets into one 'auto' snippet. I also learned that goDebugConfiguration translates 'auto' to 'debug'/'test' depending on the open file in the editor, not based on the 'program' attribute, which is good. For 'program', recommend fileDirname, instead of file for package mode. Change-Id: Ia6d4fb502cc904f13ea096a61f8888ba7d92db57 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/308493 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
1 parent d6e513e commit 44b7d36

File tree

3 files changed

+11
-32
lines changed

3 files changed

+11
-32
lines changed

docs/debugging.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Below are the available sample configurations:
174174

175175
#### Debug the current file (`Go: Launch file`)
176176

177-
Recall that `${file}` refers to the currently opened file (see [Using VS Code Variables](#using-vs-code-variables)).
177+
Recall that `${file}` refers to the currently opened file (see [Using VS Code Variables](#using-vs-code-variables)). For debugging a package that consists with multiple files, use `${fileDirname}` instead.
178178

179179
```json5
180180
{
@@ -206,7 +206,8 @@ Recall that `${workspaceFolder}` refers to the current workspace (see [Using VS
206206

207207
#### Debug all tests in the given package (`Go: Launch test package`)
208208

209-
Recall that `${workspaceFolder}` refers to the current workspace (see [Using VS Code Variables](#using-vs-code-variables)).
209+
A package is a collection of source files in the same directory that are compiled together.
210+
Recall that `${fileDirname}` refers to the directory of the open file (see [Using VS Code Variables](#using-vs-code-variables)).
210211

211212
```json5
212213
{

package.json

+2-13
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,12 @@
438438
"configurationSnippets": [
439439
{
440440
"label": "Go: Launch package",
441-
"description": "Debug the package in the program attribute",
441+
"description": "Debug/test the package in the program attribute",
442442
"body": {
443443
"name": "${2:Launch Package}",
444444
"type": "go",
445445
"request": "launch",
446-
"mode": "debug",
446+
"mode": "auto",
447447
"program": "^\"\\${workspaceFolder}${1:}\""
448448
}
449449
},
@@ -458,17 +458,6 @@
458458
"program": "^\"${1:\\${file\\}}\""
459459
}
460460
},
461-
{
462-
"label": "Go: Launch test package",
463-
"description": "Debug the test package in the program attribute",
464-
"body": {
465-
"name": "${2:Launch test package}",
466-
"type": "go",
467-
"request": "launch",
468-
"mode": "test",
469-
"program": "^\"\\${workspaceFolder}${1:}\""
470-
}
471-
},
472461
{
473462
"label": "Go: Launch test function",
474463
"description": "Debug the test function in the args, ensure program attributes points to right package",

src/goDebugConfiguration.ts

+6-17
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
3434
public async pickConfiguration(): Promise<vscode.DebugConfiguration[]> {
3535
const debugConfigurations = [
3636
{
37-
label: 'Go: Launch package',
38-
description: 'Debug the package in the program attribute',
37+
label: 'Go: Launch Package',
38+
description: 'Debug/test the package of the open file',
3939
config: {
4040
name: 'Launch Package',
4141
type: this.defaultDebugAdapterType,
4242
request: 'launch',
43-
mode: 'debug',
44-
program: '${workspaceFolder}'
43+
mode: 'auto',
44+
program: '${fileDirname}'
4545
}
4646
},
4747
{
48-
label: 'Go: Launch file',
48+
label: 'Go: Launch File',
4949
description: 'Debug the file in the program attribute',
5050
config: {
5151
name: 'Launch file',
@@ -55,17 +55,6 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
5555
program: '${file}'
5656
}
5757
},
58-
{
59-
label: 'Go: Launch test package',
60-
description: 'Debug the test package in the program attribute',
61-
config: {
62-
name: 'Launch test package',
63-
type: 'go',
64-
request: 'launch',
65-
mode: 'test',
66-
program: '${workspaceFolder}'
67-
}
68-
},
6958
{
7059
label: 'Go: Launch test function',
7160
description: 'Debug the test function in the args, ensure program attributes points to right package',
@@ -74,7 +63,7 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
7463
type: 'go',
7564
request: 'launch',
7665
mode: 'test',
77-
program: '${workspaceFolder}',
66+
program: '${fileDirname}',
7867
args: ['-test.run', 'MyTestFunction']
7968
},
8069
fill: async (config: vscode.DebugConfiguration) => {

0 commit comments

Comments
 (0)