Skip to content

Commit 318539d

Browse files
firelizzard18hyangah
authored andcommitted
src/goTest/profile: fix tree view action
Fixes opening a profile by clicking on it in the tree view. Change-Id: Ide778e894e431b430ea2aad2451b4c043ac25289 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/440530 Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Suzy Mueller <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent 02fafd6 commit 318539d

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

docs/commands.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ Run a test and capture a profile
7979

8080
Delete selected profile
8181

82+
### `Go: Show pprof file`
83+
84+
Internal use. Open a pprof profile file.
85+
8286
### `Go: Benchmark Package`
8387

8488
Runs all benchmarks in the package of the current file.

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@
284284
"description": "Delete selected profile",
285285
"category": "Test"
286286
},
287+
{
288+
"command": "go.test.showProfileFile",
289+
"title": "Go: Show pprof file",
290+
"description": "Internal use. Open a pprof profile file."
291+
},
287292
{
288293
"command": "go.benchmark.package",
289294
"title": "Go: Benchmark Package",
@@ -2675,6 +2680,10 @@
26752680
"command": "go.test.deleteProfile",
26762681
"when": "false"
26772682
},
2683+
{
2684+
"command": "go.test.showProfileFile",
2685+
"when": "false"
2686+
},
26782687
{
26792688
"command": "go.explorer.refresh",
26802689
"when": "false"

src/goTest/explore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ export class GoTestExplorer {
129129
})
130130
);
131131

132+
context.subscriptions.push(
133+
vscode.commands.registerCommand('go.test.showProfileFile', async (file: Uri) => {
134+
return inst.profiler.showFile(file.fsPath);
135+
})
136+
);
137+
132138
context.subscriptions.push(
133139
workspace.onDidChangeConfiguration(async (x) => {
134140
try {

src/goTest/profile.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ export class GoTestProfiler {
122122
await runs[0].show();
123123
}
124124

125+
showFile(file: string) {
126+
return show(file);
127+
}
128+
125129
// Tests that have been profiled
126130
get tests() {
127131
const items = Array.from(this.runs.keys());
@@ -298,7 +302,7 @@ class ProfileTreeDataProvider implements TreeDataProvider<TreeElement> {
298302
item.contextValue = 'go:test:file';
299303
item.command = {
300304
title: 'Open',
301-
command: 'vscode.open',
305+
command: 'go.test.showProfileFile',
302306
arguments: [element.uri]
303307
};
304308
return item;

0 commit comments

Comments
 (0)