mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: preserve viewport when applying diffs to active editor
- Check if file is already the active editor before re-opening - Prevents viewport jump to top when applying diffs - Applied fix to saveChanges, revertChanges, and saveDirectly methods - Addresses issue #8112
This commit is contained in:
parent
87b45def18
commit
54c49168f4
1 changed files with 31 additions and 10 deletions
|
|
@ -207,7 +207,15 @@ export class DiffViewProvider {
|
|||
await updatedDocument.save()
|
||||
}
|
||||
|
||||
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false, preserveFocus: true })
|
||||
// Check if the file is already the active editor to avoid viewport jump
|
||||
const activeEditor = vscode.window.activeTextEditor
|
||||
const isAlreadyActive = activeEditor && arePathsEqual(activeEditor.document.uri.fsPath, absolutePath)
|
||||
|
||||
if (!isAlreadyActive) {
|
||||
// Only show the document if it's not already the active editor
|
||||
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false, preserveFocus: true })
|
||||
}
|
||||
|
||||
await this.closeAllDiffViews()
|
||||
|
||||
// Getting diagnostics before and after the file edit is a better approach than
|
||||
|
|
@ -405,10 +413,17 @@ export class DiffViewProvider {
|
|||
await updatedDocument.save()
|
||||
|
||||
if (this.documentWasOpen) {
|
||||
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
|
||||
preview: false,
|
||||
preserveFocus: true,
|
||||
})
|
||||
// Check if the file is already the active editor to avoid viewport jump
|
||||
const activeEditor = vscode.window.activeTextEditor
|
||||
const isAlreadyActive = activeEditor && arePathsEqual(activeEditor.document.uri.fsPath, absolutePath)
|
||||
|
||||
if (!isAlreadyActive) {
|
||||
// Only show the document if it's not already the active editor
|
||||
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
|
||||
preview: false,
|
||||
preserveFocus: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
await this.closeAllDiffViews()
|
||||
|
|
@ -661,11 +676,17 @@ export class DiffViewProvider {
|
|||
// Open the document to ensure diagnostics are loaded
|
||||
// When openFile is false (PREVENT_FOCUS_DISRUPTION enabled), we only open in memory
|
||||
if (openFile) {
|
||||
// Show the document in the editor
|
||||
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
|
||||
preview: false,
|
||||
preserveFocus: true,
|
||||
})
|
||||
// Check if the file is already the active editor to avoid viewport jump
|
||||
const activeEditor = vscode.window.activeTextEditor
|
||||
const isAlreadyActive = activeEditor && arePathsEqual(activeEditor.document.uri.fsPath, absolutePath)
|
||||
|
||||
if (!isAlreadyActive) {
|
||||
// Only show the document if it's not already the active editor
|
||||
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
|
||||
preview: false,
|
||||
preserveFocus: true,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// Just open the document in memory to trigger diagnostics without showing it
|
||||
const doc = await vscode.workspace.openTextDocument(vscode.Uri.file(absolutePath))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue