Skip to content

Commit f9fce59

Browse files
committed
fix(lsp): handle ShowDocumentParams.external
Problem: LSP server can't open URLs, because the LSP client does not correctly handle `ShowDocumentParams.external` requests. LSP spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#showDocumentParams Solution: When `ShowDocumentParams.external` is true, open the URL in a web browser instead of as a editor document.
1 parent 6e69d40 commit f9fce59

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,21 @@ export function registerMessageListeners(
435435
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
436436
try {
437437
const uri = vscode.Uri.parse(params.uri)
438+
439+
if (params.external) {
440+
// Note: Not using openUrl() because we probably don't want telemetry for these URLs.
441+
// Also it doesn't yet support the required HACK below.
442+
443+
// HACK: workaround vscode bug: https://github.com/microsoft/vscode/issues/85930
444+
vscode.env.openExternal(params.uri as any).then(undefined, (e) => {
445+
// TODO: getLogger('?').error('failed vscode.env.openExternal: %O', e)
446+
vscode.env.openExternal(uri).then(undefined, (e) => {
447+
// TODO: getLogger('?').error('failed vscode.env.openExternal: %O', e)
448+
})
449+
})
450+
return params
451+
}
452+
438453
const doc = await vscode.workspace.openTextDocument(uri)
439454
await vscode.window.showTextDocument(doc, { preview: false })
440455
return params

0 commit comments

Comments
 (0)