Skip to content

Commit fa7a099

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 9fd15ad commit fa7a099

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,18 @@ export function registerMessageListeners(
433433
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
434434
try {
435435
const uri = vscode.Uri.parse(params.uri)
436+
437+
if (params.external) {
438+
// Don't use openUrl() because we don't want telemetry (URLs may be auth-related).
439+
try {
440+
// HACK: workaround vscode bug: https://github.com/microsoft/vscode/issues/85930
441+
vscode.env.openExternal(params.uri as any)
442+
} catch {
443+
vscode.env.openExternal(uri)
444+
}
445+
return params
446+
}
447+
436448
const doc = await vscode.workspace.openTextDocument(uri)
437449
await vscode.window.showTextDocument(doc, { preview: false })
438450
return params

0 commit comments

Comments
 (0)