Skip to content

Commit d26f4c2

Browse files
committed
Be smarter about reloading
1 parent 6c3823d commit d26f4c2

4 files changed

Lines changed: 18 additions & 17 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "ethan-reesor",
44
"displayName": "Go Companion",
55
"description": "An unofficial companion to the official Go extension, providing experimental features",
6-
"version": "0.0.12",
6+
"version": "0.0.13",
77
"icon": "docs/assets/icon.png",
88
"license": "MIT",
99
"homepage": "https://github.com/firelizzard18/exp-vscode-go",

src/go-generate/manager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ export class GoGenerateManager {
3535
storageUri: ctx.storageUri,
3636
output: window.createOutputChannel('Go Generate', { log: true }),
3737
commands: {
38-
modules: (args) => commands.executeCommand('gopls.modules', args),
39-
packages: (args) => commands.executeCommand('gopls.packages', args),
38+
// These should never be called.
39+
modules: () => {
40+
throw new Error('Internal error');
41+
},
42+
packages: () => {
43+
throw new Error('Internal error');
44+
},
4045
},
4146
};
4247
const { event } = helpers(ctx, testCtx, commands);

src/test/manager.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ export class TestManager {
5656
createTestController(id: string, label: string): TestController;
5757
},
5858
) {
59-
// Verify that gopls is new enough to support the packages command
60-
try {
61-
await this.context.commands.packages({ Files: [] });
62-
} catch (error) {
63-
if (!`${error}`.match(/^Error: command '.*' not found$/)) {
64-
throw error;
65-
}
66-
67-
await args.showWarningMessage('gopls is not installed or does not support test discovery');
68-
return;
69-
}
70-
7159
// Register the legacy code lens provider
7260
this.#disposable.push(
7361
args.registerCodeLensProvider({ language: 'go', scheme: 'file', pattern: '**/*_test.go' }, this.#codeLens),

src/test/register.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,16 @@ async function registerTestController(ctx: ExtensionContext, testCtx: Context) {
107107
await maybeChangedEnabled();
108108
});
109109

110-
// [Event] File open
111-
event(workspace.onDidOpenTextDocument, 'opened document', (e) => manager.enabled && manager.reloadUri(e.uri));
110+
// [Event] The user opened a file in an editor
111+
let seenDocuments = new Set<string>();
112+
event(window.onDidChangeVisibleTextEditors, 'opened document', (editors) => {
113+
for (const editor of editors) {
114+
if (seenDocuments.has(`${editor.document.uri}`)) continue;
115+
manager.reloadUri(editor.document.uri);
116+
}
117+
118+
seenDocuments = new Set(editors.map((x) => `${x.document.uri}`));
119+
});
112120

113121
// [Event] File change
114122
event(workspace.onDidChangeTextDocument, 'updated document', async (e) => {

0 commit comments

Comments
 (0)