Skip to content

[BUG] Preserve viewport when applying diffs to the active editor (avoid re-open) #8112

@hannesrudolph

Description

@hannesrudolph

Type

Bug

Problem / Value

When Roo edits a file you’re currently viewing, the editor jumps to the top. This breaks flow and forces constant scrolling, especially in large files. Keeping your place preserves context and saves time.

Context

Affects anyone working in an already-open file while Roo applies a diff or saves changes during a task. Happens repeatedly within a session when edits are applied to the same file you’re viewing.

Reproduction

1 Open a file in VS Code and have Roo apply a diff to that same file
2) Expected result: The viewport stays where it was so you can continue reading or editing
3) Actual result: The editor jumps to the top, losing your place

Constraints/Preferences (scoping from maintainer guidance)

  • Root cause: re-opening the document resets the viewport to the top
  • When the target file is already the active editor, do not re-open it or switch to a diff view; apply the change in-place to keep the current viewport
  • Continue to use the diff UI when the target file is not already open
  • Cover normal edits, direct saves (focus-disruption prevention mode), and reverts
  • Avoid approaches that “capture/restore cursor” since only selection state is exposed; preserve position by not re-opening

Related: #6853 (prior attempt #6855 was closed based on this guidance)
BODY
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue - Unassigned / ActionableClear and approved. Available for contributors to pick up.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Issue [Unassigned]

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions