Skip to content

Commit b0d47a8

Browse files
committed
src/goExplorer.ts: consolidate tools information into single tree item
For #2049 Change-Id: Idc23f0b10263d1988a1a20fe619a6a8ebc73b2d2 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/391255 Trust: Jamal Carvalho <[email protected]> Run-TryBot: Jamal Carvalho <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent 3999594 commit b0d47a8

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

src/goExplorer.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,9 @@ class ToolTreeItem implements vscode.TreeItem {
216216
constructor({ name, version, goVersion, binPath, error }: ToolDetail) {
217217
this.label = name;
218218
if (binPath) {
219-
this.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed;
220-
this.children = [new ToolDetailTreeItem(binPath, goVersion)];
221-
this.description = version;
222-
this.tooltip = `${name}@${version}`;
219+
this.label = `${name}@${version}`;
220+
this.description = `${replaceHome(binPath)} ${goVersion}`;
221+
this.tooltip = `${this.label} ${this.description}`;
223222
}
224223
if (error) {
225224
const msg = `go version -m failed: ${error}`;
@@ -233,18 +232,6 @@ function isToolTreeItem(item?: vscode.TreeItem): item is ToolTreeItem {
233232
return item?.contextValue === 'go:explorer:toolitem';
234233
}
235234

236-
class ToolDetailTreeItem implements vscode.TreeItem {
237-
contextValue = 'go:explorer:tooldetail';
238-
label: string;
239-
description: string;
240-
tooltip: string;
241-
constructor(bin: string, goVersion: string) {
242-
this.label = replaceHome(bin);
243-
this.description = goVersion;
244-
this.tooltip = `${bin} ${goVersion}`;
245-
}
246-
}
247-
248235
interface ToolDetail {
249236
name: string;
250237
goVersion?: string;

test/integration/goExplorer.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ suite('GoExplorerProvider', () => {
5656
const expectTools = allTools.map((t) => t.name);
5757
const [, tools] = await explorer.getChildren();
5858
const items = (await explorer.getChildren(tools)) as TreeItem[];
59-
assert.deepStrictEqual(
60-
items.map((t) => t.label),
61-
expectTools
62-
);
59+
for (const idx in items) {
60+
assert(
61+
items[idx].label.toString().startsWith(expectTools[idx]),
62+
`Unexpected tool tree item with label "${items[idx].label}"`
63+
);
64+
}
6365
});
6466
});

0 commit comments

Comments
 (0)