|
6 | 6 | import * as vscode from 'vscode' |
7 | 7 | import * as path from 'path' |
8 | 8 | import { getLogger } from 'aws-core-vscode/shared' |
9 | | -import { FsWriteParams } from './types' |
10 | | - |
11 | 9 | 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 | +} |
12 | 20 |
|
13 | 21 | type StreamingSession = { |
14 | 22 | filePath: string |
@@ -393,8 +401,7 @@ export class StreamingDiffController implements vscode.Disposable { |
393 | 401 | * Scroll editor to line |
394 | 402 | */ |
395 | 403 | 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) |
398 | 405 | } |
399 | 406 |
|
400 | 407 | isStreamingActive(toolUseId: string): boolean { |
@@ -449,10 +456,7 @@ export class StreamingDiffController implements vscode.Disposable { |
449 | 456 | // Clear decorations immediately |
450 | 457 | session.fadedOverlayController.clear() |
451 | 458 | 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 |
456 | 460 | if (document) { |
457 | 461 | try { |
458 | 462 | await document.save() |
@@ -494,10 +498,11 @@ export class StreamingDiffController implements vscode.Disposable { |
494 | 498 | private async cleanupSessions(toolUseIds: Set<string>): Promise<void> { |
495 | 499 | for (const toolUseId of toolUseIds) { |
496 | 500 | const sessionToCleanup = this.activeStreamingSessions.get(toolUseId) |
497 | | - if (sessionToCleanup) { |
498 | | - sessionToCleanup.disposed = true |
499 | | - this.activeStreamingSessions.delete(toolUseId) |
| 501 | + if (!sessionToCleanup) { |
| 502 | + continue |
500 | 503 | } |
| 504 | + sessionToCleanup.disposed = true |
| 505 | + this.activeStreamingSessions.delete(toolUseId) |
501 | 506 | } |
502 | 507 | } |
503 | 508 |
|
|
0 commit comments