Skip to main content

Module pending_synthetic_highlights

Module pending_synthetic_highlights 

Source
Expand description

Pending synthetic-buffer highlights mechanism (MG.2).

A shared service that decouples async refresh tasks (e.g. magit status buffer rebuild) from the Editor’s tick drain. The async task:

  1. Computes per-line StyledSpan vectors.
  2. Stores them in map keyed by BufferId.
  3. Fires waker (the Editor’s async_landed Notify).

On the next tick, Editor::drain_pending_synthetic_highlights drains the map into each buffer’s ExtraHighlights BufferLocal.

Uses only tokio for the waker; lattice-cells / lattice-core for the span and buffer-id types. No host or mode dependencies.

Structs§

HighlightsUpdate
One op’s worth of published highlighting — foreground spans plus, optionally, intra-line diff refinement (DR.3, 2026-08-12).
PendingSyntheticHighlights
Shared state between async refresh tasks and the Editor’s tick drain.

Enums§

HighlightsOp
Entry in the pending highlights map: a full replacement, or a splice (insert or remove) that shifts every subsequent line’s spans to stay aligned with a text edit that inserted/removed lines at the same position.

Functions§

splice_insert
Splice spans into base at start_line, shifting everything at or after start_line down by spans.len(). Pulled out as a pure function (rather than inlined at the drain call site) so the line-offset arithmetic — the exact thing that regressed into an in-place overwrite once already — has its own unit tests. DR.3: generic over the span type so foreground spans and intra-line refinement are shifted by ONE implementation. Two copies of this arithmetic is precisely how the two lists drift apart.
splice_remove
Remove count lines from base starting at start_line, shifting everything after them up by count. Exact inverse of splice_insert.

Type Aliases§

PendingSyntheticHighlightsHandle
The shared handle a producer keeps (e.g. in its Guard or a spawned task).