fix: fix diffview scoll display (#3783)

This commit is contained in:
axb 2025-05-21 21:32:17 +08:00 committed by GitHub
parent 7d99689031
commit 3c73684729
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -122,7 +122,7 @@ export class DiffViewProvider {
const endLine = accumulatedLines.length
// Replace all content up to the current line with accumulated lines.
const edit = new vscode.WorkspaceEdit()
const rangeToReplace = new vscode.Range(0, 0, endLine + 1, 0)
const rangeToReplace = new vscode.Range(0, 0, endLine, 0)
const contentToReplace = accumulatedLines.slice(0, endLine + 1).join("\n") + "\n"
edit.replace(document.uri, rangeToReplace, this.stripAllBOMs(contentToReplace))
await vscode.workspace.applyEdit(edit)
@ -130,7 +130,10 @@ export class DiffViewProvider {
this.activeLineController.setActiveLine(endLine)
this.fadedOverlayController.updateOverlayAfterLine(endLine, document.lineCount)
// Scroll to the current line.
this.scrollEditorToLine(endLine)
const ranges = this.activeDiffEditor?.visibleRanges
if (ranges && ranges.length > 0 && ranges[0].start.line < endLine && ranges[0].end.line > endLine) {
this.scrollEditorToLine(endLine)
}
// Update the streamedLines with the new accumulated content.
this.streamedLines = accumulatedLines