Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion packages/amazonq/src/lsp/chat/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
ShowDocumentRequest,
contextCommandsNotificationType,
ContextCommandParams,
openFileDiffNotificationType,
OpenFileDiffParams,
LINK_CLICK_NOTIFICATION_METHOD,
LinkClickParams,
INFO_LINK_CLICK_NOTIFICATION_METHOD,
Expand All @@ -50,7 +52,7 @@ import * as jose from 'jose'
import { AmazonQChatViewProvider } from './webviewProvider'
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
import { AmazonQPromptSettings, messages, openUrl } from 'aws-core-vscode/shared'
import { DefaultAmazonQAppInitContext, messageDispatcher } from 'aws-core-vscode/amazonq'
import { DefaultAmazonQAppInitContext, messageDispatcher, EditorContentController } from 'aws-core-vscode/amazonq'

export function registerLanguageServerEventListener(languageClient: LanguageClient, provider: AmazonQChatViewProvider) {
languageClient.info(
Expand Down Expand Up @@ -395,6 +397,23 @@ export function registerMessageListeners(
params: params,
})
})

languageClient.onNotification(openFileDiffNotificationType.method, async (params: OpenFileDiffParams) => {
const edc = new EditorContentController()
const uri = params.originalFileUri
const doc = await vscode.workspace.openTextDocument(uri)
const entireDocumentSelection = new vscode.Selection(
new vscode.Position(0, 0),
new vscode.Position(doc.lineCount - 1, doc.lineAt(doc.lineCount - 1).text.length)
)
await edc.viewDiff({
context: {
activeFileContext: { filePath: params.originalFileUri },
focusAreaContext: { selectionInsideExtendedCodeBlock: entireDocumentSelection },
},
code: params.fileContent,
})
})
}

function isServerEvent(command: string) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/amazonq/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export * as authConnection from '../auth/connection'
export * as featureConfig from './webview/generators/featureConfig'
export * as messageDispatcher from './webview/messages/messageDispatcher'
import { FeatureContext } from '../shared/featureConfig'
export { EditorContentController } from './commons/controllers/contentController'

/**
* main from createMynahUI is a purely browser dependency. Due to this
Expand Down