Skip to content

Commit 3c73684

Browse files
authored
fix: fix diffview scoll display (RooCodeInc#3783)
1 parent 7d99689 commit 3c73684

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,18 @@ export class DiffViewProvider {
122122
const endLine = accumulatedLines.length
123123
// Replace all content up to the current line with accumulated lines.
124124
const edit = new vscode.WorkspaceEdit()
125-
const rangeToReplace = new vscode.Range(0, 0, endLine + 1, 0)
125+
const rangeToReplace = new vscode.Range(0, 0, endLine, 0)
126126
const contentToReplace = accumulatedLines.slice(0, endLine + 1).join("\n") + "\n"
127127
edit.replace(document.uri, rangeToReplace, this.stripAllBOMs(contentToReplace))
128128
await vscode.workspace.applyEdit(edit)
129129
// Update decorations.
130130
this.activeLineController.setActiveLine(endLine)
131131
this.fadedOverlayController.updateOverlayAfterLine(endLine, document.lineCount)
132132
// Scroll to the current line.
133-
this.scrollEditorToLine(endLine)
133+
const ranges = this.activeDiffEditor?.visibleRanges
134+
if (ranges && ranges.length > 0 && ranges[0].start.line < endLine && ranges[0].end.line > endLine) {
135+
this.scrollEditorToLine(endLine)
136+
}
134137

135138
// Update the streamedLines with the new accumulated content.
136139
this.streamedLines = accumulatedLines

0 commit comments

Comments
 (0)