Skip to content

Side-by-side Git diff: skip the realign when an update leaves the padding unchanged #19250

Description

@kevinushey

Follow-up to #19212 (side-by-side Git diff), from the review discussion there.

Background

The side-by-side view (src/gwt/acesupport/git_diff_split.js) realigns the two panes from scratch on every gutter update: align() removes and re-adds every padding widget, resets both sessions' row caches from row 0, and emits changeFold on both sessions, which forces a full render of each. That happens on most keystrokes while the view is open, including ones that change nothing about the alignment, such as typing inside a line that is already modified.

Skipping align() when the chunks' row ranges match the previous call is not safe on its own: the padding is computed from screen rows, so with soft wrap a keystroke inside an already-changed line can wrap it onto another screen row and change the padding needed at the next change boundary without any chunk row changing.

Updates are already coalesced (a microtask, or a typing pause when the diff is slow), which bounds the cost; this is a polish item.

Proposal

Compute the padding set (session, row, rowCount, rowsAbove) first and compare it against what is in place, applying and signalling only when it differs. That means taking over Ace's SplitDiffView.align() rather than calling it, since Ace clears and re-adds in one pass.

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

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions