Skip to main content

compute_diff_sign_map

Function compute_diff_sign_map 

Source
pub fn compute_diff_sign_map(hunks: &HunkIndex) -> DiffSignMap
Expand description

D.3.d.0: derive a DiffSignMap from a HunkIndex.

Walks each hunk’s current-side range (ranges[1]):

  • Add → every line in the range gets Add.
  • Change / Conflict → every line in the range gets Change (the current-side rows are the replacements).
  • Remove → no current-side lines exist; the deletion is surfaced through the virtual-row deletion block (D.3.b) and gets no sign in the sign map. Renderers wanting to sign the insertion point of a removed hunk should render based on the deletion block’s anchor line (a future D.3.d.1 detail) — keeping the sign map a strictly-current-rope decoration here avoids double-counting at the deletion anchor.

Entries are sorted by line before return so DiffSignMap::sign_at binary-searches cheaply.