Skip to main content

pair_split_view

Function pair_split_view 

Source
pub fn pair_split_view(hunk: &Hunk) -> Vec<SplitRow>
Expand description

Pair context / removed / added lines for one hunk into left/right rows suitable for side-by-side rendering.

Algorithm (matches the brief):

  • Walk the lines in source order.
  • Context → duplicate text into BOTH left and right.
  • Removed → push into left, leave right = None.
  • Added → push into right, leave left = None.
  • Adjacent Removed-then-Added (and Added-then-Removed) pairs line up at the same row index so the visual gutter reads as a unified diff flipped sideways.
  • Lone runs of one side collapse to per-row Nones so the renderer doesn’t waste vertical space on blank halves.