Skip to content

Commit

Permalink
extension/src/language: surface code action error as notification
Browse files Browse the repository at this point in the history
Updated bug fixes in changelog.

By default, the vscode-languageserver-node client discard the error
returned from the language server. The error is burried in
"gopls(server) output". This CL capture the error returned from the
gopls and surface them through vscode message notification.

Change-Id: I1e0beca6c833ed0c95275de3d0f3c429f0c5b733
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/648937
Reviewed-by: Robert Findley <[email protected]>
kokoro-CI: kokoro <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
h9jiang committed Feb 18, 2025
1 parent e10c953 commit f0d9221
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

* Added new "Package Outline" explorer view that displays all the symbols in the currently open file's package.

### Fixes

* Improved Error Reporting: Code action resolution failures now display error messages via notifications from gopls.
* Removed unnecessary prompts for missing formatter tools when gopls is enabled ([Issue 3677](https://github.com/golang/vscode-go/issues/3677)).

## v0.45.1 (prerelease)

Date: 2025-02-11
Expand Down
14 changes: 14 additions & 0 deletions extension/src/language/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,20 @@ export async function buildLanguageClient(
}
return ret;
}
},
resolveCodeAction: async (item, token, next) => {
try {
return await next(item, token);
} catch (e) {
const answer = await vscode.window.showErrorMessage(
`code action resolve failed: ${e}.`,
'Show Trace'
);
if (answer === 'Show Trace') {
goCtx.serverOutputChannel?.show();
}
return null;
}
}
}
} as LanguageClientOptions,
Expand Down

0 comments on commit f0d9221

Please sign in to comment.