From 24292759b3ece1adadcbb89d583a63d496b6741a Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Thu, 17 Oct 2024 03:46:34 -0400 Subject: [PATCH] Move cursor to beginning of file during stream animation --- src/integrations/editor/DiffViewProvider.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/integrations/editor/DiffViewProvider.ts b/src/integrations/editor/DiffViewProvider.ts index ce011ee..709bff5 100644 --- a/src/integrations/editor/DiffViewProvider.ts +++ b/src/integrations/editor/DiffViewProvider.ts @@ -90,11 +90,16 @@ export class DiffViewProvider { } const diffLines = accumulatedLines.slice(this.streamedLines.length) - const document = this.activeDiffEditor?.document - if (!document) { + const diffEditor = this.activeDiffEditor + const document = diffEditor?.document + if (!diffEditor || !document) { throw new Error("User closed text editor, unable to edit file...") } + // Place cursor at the beginning of the diff editor to keep it out of the way of the stream animation + const beginningOfDocument = new vscode.Position(0, 0) + diffEditor.selection = new vscode.Selection(beginningOfDocument, beginningOfDocument) + for (let i = 0; i < diffLines.length; i++) { const currentLine = this.streamedLines.length + i // Replace all content up to the current line with accumulated lines