diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index cf8b4f55940..147077c2647 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -32,6 +32,11 @@ import { ShowSaveFileDialogParams, LSPErrorCodes, tabBarActionRequestType, + ShowDocumentParams, + ShowDocumentResult, + ShowDocumentRequest, + contextCommandsNotificationType, + ContextCommandParams, } from '@aws/language-server-runtimes/protocol' import { v4 as uuidv4 } from 'uuid' import * as vscode from 'vscode' @@ -286,6 +291,23 @@ export function registerMessageListeners( targetUri: targetUri.toString(), } }) + + languageClient.onRequest( + ShowDocumentRequest.method, + async (params: ShowDocumentParams): Promise> => { + const uri = vscode.Uri.parse(params.uri) + const doc = await vscode.workspace.openTextDocument(uri) + await vscode.window.showTextDocument(doc, { preview: false }) + return params + } + ) + + languageClient.onNotification(contextCommandsNotificationType.method, (params: ContextCommandParams) => { + void provider.webview?.postMessage({ + command: contextCommandsNotificationType.method, + params: params, + }) + }) } function isServerEvent(command: string) { diff --git a/packages/amazonq/test/unit/amazonq/lsp/chat/messages.test.ts b/packages/amazonq/test/unit/amazonq/lsp/chat/messages.test.ts index 67022cfa80f..b2f5958f52b 100644 --- a/packages/amazonq/test/unit/amazonq/lsp/chat/messages.test.ts +++ b/packages/amazonq/test/unit/amazonq/lsp/chat/messages.test.ts @@ -27,6 +27,7 @@ describe('registerMessageListeners', () => { error: errorStub, sendNotification: sandbox.stub(), onRequest: sandbox.stub(), + onNotification: sandbox.stub(), } as unknown as LanguageClient provider = {