Skip to content

Unified Diff: Preserve cursor position and active diff when switching to/from 2-way compare #2947

Description

@tobiasmelcher

Problem

The unified diff toolbar provides an action to open the diff in the traditional 2-way compare editor. Conversely, the 2-way compare editor provides an action to switch back to the unified diff presentation. However, switching between the two presentations does not preserve context: the cursor position, scroll position, and the currently active diff hunk are lost, and the view always resets to the first diff.

Expected Behavior

When switching between unified diff and 2-way compare editor (in either direction), the following context should be restored in the target presentation:

  • The active diff hunk — the diff closest to the cursor or the one explicitly navigated to should remain selected/focused.
  • The cursor position — the caret should be placed at the equivalent location in the target editor.
  • The scroll position — the target editor should scroll to bring the active diff into view.

This makes switching between presentations a non-destructive operation and allows users to freely alternate between the two views without losing their place.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions