Skip to content

Commit a170402

Browse files
committed
address PR comments and add change logs
1 parent 75dde78 commit a170402

File tree

3 files changed

+20
-37
lines changed

3 files changed

+20
-37
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Real time diff animation will be rendered during code generation"
4+
}

packages/amazonq/src/lsp/chat/diffAnimation/streamingDiffController.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66
import * as vscode from 'vscode'
77
import * as path from 'path'
88
import { getLogger } from 'aws-core-vscode/shared'
9-
import { FsWriteParams } from './types'
10-
119
export const diffViewUriScheme = 'amazonq-diff'
10+
interface FsWriteParams {
11+
command?: string
12+
insertLine?: number
13+
oldStr?: string
14+
newStr?: string
15+
fileText?: string
16+
explanation?: string
17+
pairIndex?: number
18+
totalPairs?: number
19+
}
1220

1321
type StreamingSession = {
1422
filePath: string
@@ -393,8 +401,7 @@ export class StreamingDiffController implements vscode.Disposable {
393401
* Scroll editor to line
394402
*/
395403
private scrollEditorToLine(editor: vscode.TextEditor, line: number): void {
396-
const scrollLine = line
397-
editor.revealRange(new vscode.Range(scrollLine, 0, scrollLine, 0), vscode.TextEditorRevealType.InCenter)
404+
editor.revealRange(new vscode.Range(line, 0, line, 0), vscode.TextEditorRevealType.InCenter)
398405
}
399406

400407
isStreamingActive(toolUseId: string): boolean {
@@ -449,10 +456,7 @@ export class StreamingDiffController implements vscode.Disposable {
449456
// Clear decorations immediately
450457
session.fadedOverlayController.clear()
451458
session.activeLineController.clear()
452-
453-
// Save the temp file one final time
454-
const diffEditor = session.activeDiffEditor
455-
const document = diffEditor?.document
459+
const document = session.activeDiffEditor?.document
456460
if (document) {
457461
try {
458462
await document.save()
@@ -494,10 +498,11 @@ export class StreamingDiffController implements vscode.Disposable {
494498
private async cleanupSessions(toolUseIds: Set<string>): Promise<void> {
495499
for (const toolUseId of toolUseIds) {
496500
const sessionToCleanup = this.activeStreamingSessions.get(toolUseId)
497-
if (sessionToCleanup) {
498-
sessionToCleanup.disposed = true
499-
this.activeStreamingSessions.delete(toolUseId)
501+
if (!sessionToCleanup) {
502+
continue
500503
}
504+
sessionToCleanup.disposed = true
505+
this.activeStreamingSessions.delete(toolUseId)
501506
}
502507
}
503508

packages/amazonq/src/lsp/chat/diffAnimation/types.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)