Skip to content

Commit 1704fde

Browse files
committed
feat(amazonq) handle context command and open file for chat with lsp
1 parent d457022 commit 1704fde

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ import {
3232
ShowSaveFileDialogParams,
3333
LSPErrorCodes,
3434
tabBarActionRequestType,
35+
ShowDocumentParams,
36+
ShowDocumentResult,
37+
ShowDocumentRequest,
38+
contextCommandsNotificationType,
39+
ContextCommandParams,
3540
} from '@aws/language-server-runtimes/protocol'
3641
import { v4 as uuidv4 } from 'uuid'
3742
import * as vscode from 'vscode'
@@ -286,6 +291,23 @@ export function registerMessageListeners(
286291
targetUri: targetUri.toString(),
287292
}
288293
})
294+
295+
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
296+
ShowDocumentRequest.method,
297+
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
298+
const uri = vscode.Uri.parse(params.uri)
299+
const doc = await vscode.workspace.openTextDocument(uri)
300+
await vscode.window.showTextDocument(doc, { preview: false })
301+
return params
302+
}
303+
)
304+
305+
languageClient.onNotification(contextCommandsNotificationType.method, (params: ContextCommandParams) => {
306+
void provider.webview?.postMessage({
307+
command: contextCommandsNotificationType.method,
308+
params: params,
309+
})
310+
})
289311
}
290312

291313
function isServerEvent(command: string) {

0 commit comments

Comments
 (0)