Skip to main content

changed_lines

Function changed_lines 

Source
pub fn changed_lines(before: &str, after: &str) -> DiffSignMap
Expand description

One changed file’s hunks, as excerpt line ranges over the working-tree file.

Returns the post-image ranges — the lines as they exist on disk now — because that is what an excerpt anchors to and what an edit propagates into. PD.7a: post-image lines the diff touched, as a [DiffSignMap].

Delegates to lattice_diff::compute_diff_sign_map. This function used to walk the hunks itself and derive its own (line, kind) pairs, which was the same classification written twice — and drifting already: the hand-rolled version collapsed Change into Add, and had no answer for Conflict at all.

The distinction that makes this reuse rather than a workaround: diff classification is a pure function of two texts, and that is what is shared. DiffSession is the orthogonal thing — a lifecycle that watches buffers, debounces and republishes — and this view genuinely has a different one: its baselines come from git rather than from a sibling buffer, and it refreshes on a scan rather than on an edit. Depending on the pure core and not the stateful shell is the whole of the design here; manufacturing a baseline buffer per file so a session could be opened would have been contorting the data to fit the tool.