mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: improve scroll position restoration timing
- Close diff views before showing text document to avoid interference - Add 50ms delay after showing document to ensure editor is initialized - This fixes the issue where scroll position was jumping to start despite being captured - Applies to both saveChanges() and revertChanges() methods
This commit is contained in:
parent
2afbe9edf9
commit
9e57dd652a
1 changed files with 14 additions and 3 deletions
|
|
@ -214,11 +214,17 @@ export class DiffViewProvider {
|
|||
await updatedDocument.save()
|
||||
}
|
||||
|
||||
// Close diff views first to avoid interference with the text editor
|
||||
await this.closeAllDiffViews()
|
||||
|
||||
// Show the text document
|
||||
const editor = await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
|
||||
preview: false,
|
||||
preserveFocus: true,
|
||||
})
|
||||
await this.closeAllDiffViews()
|
||||
|
||||
// Add a small delay to ensure the editor is fully initialized before restoring scroll position
|
||||
await new Promise((resolve) => setTimeout(resolve, 50))
|
||||
|
||||
// Restore the cursor position and scroll position from the diff view
|
||||
// First set the selection to where the cursor was
|
||||
|
|
@ -437,12 +443,19 @@ export class DiffViewProvider {
|
|||
await vscode.workspace.applyEdit(edit)
|
||||
await updatedDocument.save()
|
||||
|
||||
// Close diff views first to avoid interference with the text editor
|
||||
await this.closeAllDiffViews()
|
||||
|
||||
if (this.documentWasOpen) {
|
||||
// Show the text document
|
||||
const editor = await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
|
||||
preview: false,
|
||||
preserveFocus: true,
|
||||
})
|
||||
|
||||
// Add a small delay to ensure the editor is fully initialized before restoring scroll position
|
||||
await new Promise((resolve) => setTimeout(resolve, 50))
|
||||
|
||||
// Restore the cursor position and scroll position from the diff view
|
||||
// First set the selection to where the cursor was
|
||||
editor.selection = selection
|
||||
|
|
@ -462,8 +475,6 @@ export class DiffViewProvider {
|
|||
editor.revealRange(new vscode.Range(midPoint, 0, midPoint, 0), vscode.TextEditorRevealType.InCenter)
|
||||
}
|
||||
}
|
||||
|
||||
await this.closeAllDiffViews()
|
||||
}
|
||||
|
||||
// Edit is done.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue