Skip to main content

Module engine

Module engine 

Source
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 HunkId allocation 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§

HunkComputation
Outcome of compute: the hunk list plus advisory warnings for the UI.
HunkIdAllocator
Allocator for HunkId values. Held by DiffState so 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_text vs new_text, in document order, with fresh ids from ids. Decisions are the caller’s job.
hunk_new_side_text
The hunk’s new-side text, trailing newlines included ("" for a Delete). The reconcile gate compares it to decide whether an external write changed a matched hunk’s target.
match_by_old_overlap
Match hunk against 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> of hunks.len() seeded to Pending; used at every recompute site.