Skip to content

Commit 1b24c07

Browse files
committed
feat: option to show diff in reverse order
1 parent 3b619b0 commit 1b24c07

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import { Disposable, LanguageClient, Position, TextDocumentIdentifier } from 'vs
5454
import * as jose from 'jose'
5555
import { AmazonQChatViewProvider } from './webviewProvider'
5656
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
57-
import { AmazonQPromptSettings, messages, openUrl } from 'aws-core-vscode/shared'
57+
import { amazonQDiffScheme, AmazonQPromptSettings, messages, openUrl } from 'aws-core-vscode/shared'
5858
import { DefaultAmazonQAppInitContext, messageDispatcher, EditorContentController } from 'aws-core-vscode/amazonq'
5959

6060
export function registerLanguageServerEventListener(languageClient: LanguageClient, provider: AmazonQChatViewProvider) {
@@ -427,13 +427,17 @@ export function registerMessageListeners(
427427
new vscode.Position(0, 0),
428428
new vscode.Position(doc.lineCount - 1, doc.lineAt(doc.lineCount - 1).text.length)
429429
)
430-
await edc.viewDiff({
431-
context: {
432-
activeFileContext: { filePath: params.originalFileUri },
433-
focusAreaContext: { selectionInsideExtendedCodeBlock: entireDocumentSelection },
430+
await edc.viewDiff(
431+
{
432+
context: {
433+
activeFileContext: { filePath: params.originalFileUri },
434+
focusAreaContext: { selectionInsideExtendedCodeBlock: entireDocumentSelection },
435+
},
436+
code: params.fileContent,
434437
},
435-
code: params.fileContent,
436-
})
438+
amazonQDiffScheme,
439+
true
440+
)
437441
})
438442
}
439443

packages/core/src/amazonq/commons/controllers/contentController.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class EditorContentController {
156156
*
157157
* @param message the message from Amazon Q chat
158158
*/
159-
public async viewDiff(message: any, scheme: string = amazonQDiffScheme) {
159+
public async viewDiff(message: any, scheme: string = amazonQDiffScheme, reverseOrder = false) {
160160
const errorNotification = 'Unable to Open Diff.'
161161
const { filePath, selection } = extractFileAndCodeSelectionFromMessage(message)
162162

@@ -170,8 +170,7 @@ export class EditorContentController {
170170
const disposable = vscode.workspace.registerTextDocumentContentProvider(scheme, contentProvider)
171171
await vscode.commands.executeCommand(
172172
'vscode.diff',
173-
originalFileUri,
174-
uri,
173+
...(reverseOrder ? [uri, originalFileUri] : [originalFileUri, uri]),
175174
`${path.basename(filePath)} ${amazonQTabSuffix}`
176175
)
177176

0 commit comments

Comments
 (0)