Skip to content

Commit 4c4556f

Browse files
committed
simplify ShowDocumentRequest handler
1 parent 39c62a5 commit 4c4556f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/amazonq/src/lsp/client.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,23 +195,22 @@ export async function startLanguageServer(
195195
client.onRequest<ShowDocumentParams, ShowDocumentResult>(
196196
ShowDocumentRequest.method,
197197
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
198+
const uri = vscode.Uri.parse(params.uri)
199+
getLogger().info(`Processing ShowDocumentRequest for URI scheme: ${uri.scheme}`)
198200
try {
199-
const uri = vscode.Uri.parse(params.uri)
200201
if (uri.scheme.startsWith('http')) {
201-
try {
202-
await openUrl(vscode.Uri.parse(params.uri))
203-
return params
204-
} catch (err: any) {
205-
getLogger().error(`Failed to open http from LSP: error: %s`, err)
206-
}
202+
getLogger().info('Opening URL...')
203+
await openUrl(vscode.Uri.parse(params.uri))
204+
} else {
205+
getLogger().info('Opening text document...')
206+
const doc = await vscode.workspace.openTextDocument(uri)
207+
await vscode.window.showTextDocument(doc, { preview: false })
207208
}
208-
const doc = await vscode.workspace.openTextDocument(uri)
209-
await vscode.window.showTextDocument(doc, { preview: false })
210209
return params
211210
} catch (e) {
212211
return new ResponseError(
213212
LSPErrorCodes.RequestFailed,
214-
`Failed to open document: ${(e as Error).message}`
213+
`Failed to process ShowDocumentRequest: ${(e as Error).message}`
215214
)
216215
}
217216
}

0 commit comments

Comments
 (0)