Skip to content

Commit e10c953

Browse files
h9jianggopherbot
authored andcommitted
extension/src: reload package symbol for only go file and file scheme
Skip vscode message for package symbol command due to high frequency. For #3681 Change-Id: If4e0749d7123d17292a9f7266e73c65c8bde332c Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/649258 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> kokoro-CI: kokoro <[email protected]>
1 parent 726029b commit e10c953

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

extension/src/goPackageOutline.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class GoPackageOutlineProvider implements vscode.TreeDataProvider<Package
3434
constructor(ctx: vscode.ExtensionContext) {
3535
this.reload(vscode.window.activeTextEditor?.document);
3636
let previousVersion: number | undefined;
37-
// Reload package symbol data on saving document with changes
37+
// Reload package symbol data on saving active document with changes.
3838
ctx.subscriptions.push(
3939
vscode.workspace.onDidSaveTextDocument((d) => {
4040
if (d.uri === vscode.window.activeTextEditor?.document.uri) {
@@ -45,12 +45,9 @@ export class GoPackageOutlineProvider implements vscode.TreeDataProvider<Package
4545
}
4646
})
4747
);
48-
// Reload package symbol data when switching active file
48+
// Reload package symbol data when switching active file.
4949
ctx.subscriptions.push(
5050
vscode.window.onDidChangeActiveTextEditor((e) => {
51-
if (!e?.document?.fileName.endsWith('.go')) {
52-
return;
53-
}
5451
this.reload(e?.document);
5552
})
5653
);
@@ -105,7 +102,7 @@ export class GoPackageOutlineProvider implements vscode.TreeDataProvider<Package
105102
}
106103

107104
async reload(e?: vscode.TextDocument) {
108-
if (!e) {
105+
if (e?.languageId !== 'go' || e?.uri?.scheme !== 'file') {
109106
this.result = undefined;
110107
this.activeDocument = undefined;
111108
return;

extension/src/language/goLanguageServer.ts

+4
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ export async function buildLanguageClient(
590590

591591
return res;
592592
} catch (e) {
593+
// Suppress error messages for frequently triggered commands.
594+
if (command === 'gopls.package_symbols') {
595+
return null;
596+
}
593597
// TODO: how to print ${e} reliably???
594598
const answer = await vscode.window.showErrorMessage(
595599
`Command '${command}' failed: ${e}.`,

0 commit comments

Comments
 (0)