Expand description
Pure data layer for Lattice’s diff subsystem.
Arity-agnostic hunk computation over &ropey::Rope inputs,
backed by [imara_diff] (Histogram by default; Myers +
Patience also wired). No host integration, no actor
plumbing – those land in D.2.
compute_diff is the only public engine entry: pass an
&[Rope] of N participants (N ∈ {0, 1, 2, 3} in v1), get
back a Result<HunkIndex, DiffEngineError>. The engine
dispatches by arity to crate-private two-way / three-way
algorithms; external consumers never branch on N. See
docs/dev/architecture/n-way-diff-membership.md (D.8) for
the design rationale.
See docs/dev/architecture/diff-system.md §3.1 for the type
model and §4 for the engine choice.
§Example
use lattice_diff::{compute_diff, DiffAlgorithm, HunkKind};
use ropey::Rope;
let a = Rope::from("alpha\nbeta\ngamma\n");
let b = Rope::from("alpha\nBETA\ngamma\n");
let hunks = compute_diff(&[a, b], DiffAlgorithm::Histogram)
.expect("two-way is supported");
assert_eq!(hunks.hunks.len(), 1);
assert_eq!(hunks.hunks[0].kind, HunkKind::Change);Re-exports§
pub use compute::DiffEngineError;pub use compute::compute_diff;pub use install::install;pub use programmatic::ProgrammaticDiffBus;pub use programmatic::ProgrammaticDiffRequest;pub use refine::RegionRefinement;pub use refine::refine_regions;pub use types::DiffAlgorithm;pub use types::Hunk;pub use types::HunkIndex;pub use types::HunkKind;pub use types::LineRange;
Modules§
- compute
- Hunk computation: the engine’s single public entry point is
compute_diff, which dispatches by participant count to crate-private [two_way] / [three_way] helpers. External consumers (subsystem, benches, integration tests in other crates) go throughcompute_diffexclusively — no code outside this crate branches on arity. v1 supports N ∈ {0, 1, 2, 3}; N=0 errors asEmpty, N=1 returns an emptyHunkIndex(dormant session, no peers to diff against), N=2 / N=3 dispatch to the named helpers, N≥4 errors asUnsupported. Seedocs/dev/architecture/n-way-diff-membership.md(D.8) for the rationale. - filler
- D.4.c (2026-05-29) / D.6.b (2026-05-31): hunk-alignment filler rows.
- fold
- D.3.f.1 (2026-05-29) / DX.3-C7 (2026-06-24):
HunkFoldSource. - install
- BC.6 / DX.7 / CR.6: the crate-owned
install(boot)entry point. - mode
diff-modeminor mode + the host-side bridge that toggles it on participating buffers asDiffSessions open and close.- options
- D-fix.5 (2026-06-26): diff-presentation options, owned by the diff
subsystem ([[feedback_mode_owns_its_surface]]) rather than host
core. Self-register via
linkmelike every otheroptions!block; the host’sinit_from_linkme()walks the global slice at boot, so linkinglattice-diffinto the binary (it always is —installruns in the Phase-B list) picks these up automatically. - overlay
- D.3.a (2026-05-29) —
DiffOverlayVirtualRowProvider. - pane_
group - D.4.b (2026-05-29) / D.6.b (2026-05-31):
HunkRowMapper. - patch
- Patch application for round-trip testing.
- programmatic
- Programmatic diff requests — the host-drained “open a diff and await the
user’s verdict” capability that
DiffSession::bind_completionwas built for. - refine
- DR.1 (2026-08-12): intra-line refinement — which part of a changed line changed.
- subsystem
- D.2.a / D.2.b / D.2.c —
DiffSubsystem. - types
- Data model for the diff subsystem.