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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Amazon Q /dev: update diff window behavior after a change is accepted"
}
8 changes: 0 additions & 8 deletions packages/core/src/amazonq/commons/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,3 @@ export function createAmazonQUri(path: string, tabId: string) {
// TODO change the featureDevScheme to a more general amazon q scheme
return vscode.Uri.from({ scheme: featureDevScheme, path, query: `tabID=${tabId}` })
}

export async function openFile(path: string) {
if (!(await fs.exists(path))) {
return
}
const fileUri = vscode.Uri.file(path)
await vscode.commands.executeCommand('vscode.diff', fileUri, fileUri)
}
9 changes: 1 addition & 8 deletions packages/core/src/amazonq/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ export { amazonQHelpUrl } from '../shared/constants'
export { listCodeWhispererCommandsWalkthrough } from '../codewhisperer/ui/statusBarMenu'
export { focusAmazonQPanel, focusAmazonQPanelKeybinding } from '../codewhispererChat/commands/registerCommands'
export { TryChatCodeLensProvider, tryChatCodeLensCommand } from '../codewhispererChat/editor/codelens'
export {
createAmazonQUri,
openDiff,
openDeletedDiff,
getOriginalFileUri,
getFileDiffUris,
openFile,
} from './commons/diff'
export { createAmazonQUri, openDiff, openDeletedDiff, getOriginalFileUri, getFileDiffUris } from './commons/diff'
export { CodeReference } from '../codewhispererChat/view/connector/connector'
export { AuthMessageDataMap, AuthFollowUpType } from './auth/model'
export { extractAuthFollowUp } from './util/authUtils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { openUrl } from '../../../shared/utilities/vsCodeUtils'
import { getPathsFromZipFilePath } from '../../util/files'
import { examples, messageWithConversationId } from '../../userFacingText'
import { getWorkspaceFoldersByPrefixes } from '../../../shared/utilities/workspaceUtils'
import { openDeletedDiff, openDiff, openFile } from '../../../amazonq/commons/diff'
import { openDeletedDiff, openDiff } from '../../../amazonq/commons/diff'
import { i18n } from '../../../shared/i18n-helper'
import globals from '../../../shared/extensionGlobals'
import { randomUUID } from '../../../shared'
Expand Down Expand Up @@ -750,7 +750,7 @@ export class FeatureDevController {
this.sendAcceptCodeTelemetry(session, 1)
await session.insertNewFiles([session.state.filePaths[filePathIndex]])
await session.insertCodeReferenceLogs(session.state.references ?? [])
await this.openFile(session.state.filePaths[filePathIndex])
await this.openFile(session.state.filePaths[filePathIndex], tabId)
} else {
session.state.filePaths[filePathIndex].rejected = !session.state.filePaths[filePathIndex].rejected
}
Expand Down Expand Up @@ -828,9 +828,10 @@ export class FeatureDevController {
}
}

private async openFile(filePath: NewFileInfo) {
const absolutePath = path.join(filePath.workspaceFolder.uri.fsPath, filePath.relativePath)
await openFile(absolutePath)
private async openFile(filePath: NewFileInfo, tabId: string) {
const leftPath = path.join(filePath.workspaceFolder.uri.fsPath, filePath.relativePath)
const rightPath = filePath.virtualMemoryUri.path
await openDiff(leftPath, rightPath, tabId)
}

private async stopResponse(message: any) {
Expand Down
26 changes: 1 addition & 25 deletions packages/core/src/test/amazonq/common/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ import assert from 'assert'
import * as path from 'path'
import * as vscode from 'vscode'
import sinon from 'sinon'
import {
createAmazonQUri,
getFileDiffUris,
getOriginalFileUri,
openDeletedDiff,
openDiff,
openFile,
} from '../../../amazonq'
import { createAmazonQUri, getFileDiffUris, getOriginalFileUri, openDeletedDiff, openDiff } from '../../../amazonq'
import { FileSystem } from '../../../shared/fs/fs'

describe('diff', () => {
Expand Down Expand Up @@ -119,21 +112,4 @@ describe('diff', () => {
assert.deepStrictEqual(right, rightExpected)
})
})

describe('openFile', () => {
it('file exists locally', async () => {
sandbox.stub(FileSystem.prototype, 'exists').resolves(true)
await openFile(filePath)

const expected = vscode.Uri.file(filePath)
assert.ok(executeCommandSpy.calledWith('vscode.diff', expected, expected))
})

it('file does not exists locally', async () => {
sandbox.stub(FileSystem.prototype, 'exists').resolves(false)
await openFile(filePath)

assert.ok(executeCommandSpy.notCalled)
})
})
})
Loading