Skip to main content

Module filler

Module filler 

Source
Expand description

D.4.c (2026-05-29) / D.6.b (2026-05-31): hunk-alignment filler rows.

FillerRowProvider is a VirtualRowProvider that emits blank virtual rows on whichever side of a side-by-side diff is shorter for a given hunk, so the hunks align visually across all panes.

Composes with D.4.a (crate::pane_group), D.4.b (crate::pane_group), and D.0a virtual rows (lattice_cells::VirtualRowProvider); consumed by D.4.d (:diffsplit / :diffthis two-way) and D.6.c (three-way :diffsplit base remote).

See docs/dev/architecture/diff-system.md §5.2.

§One provider per pane

A side-by-side session has N panes (2 in two-way, 3 in three-way), each showing a different buffer. Filler rows for a pane depend on that buffer’s row coordinates; the virtual-rows worker is per-document (docs/dev/architecture/virtual-rows.md §1), so we register one provider per pane, each parameterised by Side.

§Algorithm

For each hunk in the session’s published HunkIndex, given the pane’s Side:

  • Let lens[i] = hunk.ranges[i].len() for each participating side.
  • Let max_len = max(lens).
  • This pane’s this_len = lens[side.pane_index()].
  • Emit max_len - this_len filler rows on this pane (zero when this pane is already the longest).
  • Anchor: if this_len == 0 (this pane has no lines in this hunk), anchor at range.start with AnchorPosition::Above — fillers paint immediately before the insertion point. If this_len > 0, anchor at range.end - 1 with AnchorPosition::Below — fillers paint after the last changed line so the rest of the buffer aligns.

Conflict hunks: in two-way (ranges.len() == 2) they shouldn’t be emitted by compute_two_way, so the provider defensively skips them. In three-way (ranges.len() >= 3) Conflict hunks have the same row-geometry as Change for alignment purposes, so they contribute fillers normally.

Structs§

FillerRowProvider
D.4.c: one provider per (session, side) pair.

Enums§

Side
Which pane of a side-by-side session this provider emits rows for. Each variant maps to a slot index in Hunk::ranges:

Functions§

compute_filler_rows
Pure function from (HunkIndex, side) to filler rows. Exposed for direct unit testing without round-tripping through a DiffSession.
diff_filler_provider_id
D.4.c: deterministic ProviderId for the filler-row provider on buffer_id and side. Exposed as a free function so :diffoff / D.4.d teardown can unregister without holding the provider — the namespace encoding makes the id reproducible.