Expand description
Line-level + inline-word diff over two strings, producing the Hunk sequence consumed by
crate::diff::DiffState. Wraps similar::TextDiff::from_lines so nothing else imports
similar directly, and adds two things on top:
- Row-level table sub-diff: a hunk contained in a markdown table extent is split into per-row hunks (neighboring changed rows coalesced) so the user decides row by row.
- Stable
HunkIdallocation through a caller-supplied counter.
Inline word-level highlights are restricted to text lines outside table cells and reach the
renderer through crate::diff::hunk::InlineSpan.
Structs§
- Hunk
Computation - Outcome of
compute: the hunk list plus advisory warnings for the UI. - Hunk
IdAllocator - Allocator for
HunkIdvalues. Held byDiffStateso a recompute mints fresh ids rather than reusing old ones; stability across recomputes comes from old-side overlap matching (match_by_old_overlap) instead.
Functions§
- compute
- Compute the hunk list for
old_textvsnew_text, in document order, with fresh ids fromids. Decisions are the caller’s job. - hunk_
new_ side_ text - The hunk’s new-side text, trailing newlines included (
""for aDelete). The reconcile gate compares it to decide whether an external write changed a matched hunk’s target. - match_
by_ old_ overlap - Match
hunkagainst a prior hunk list by old-side overlap — the id-stability primitive shared by the reconcile path and the post-edit recompute. - pending_
decisions - A
Vec<Decision>ofhunks.len()seeded toPending; used at every recompute site.