Skip to main content

Module decorations

Module decorations 

Source
Expand description

Tracked-range decorations: the one store, one mover for diagnostics, snippet stops, auto-close regions, and find matches.

Diagnostics, snippet placeholders, and find matches are ONE mechanism — a TrackedRange carrying a DecorationKind and a Stickiness. The store holds bare current-revision byte offsets and is moved eagerly by DecorationStore::apply_patch on every commit, so a decoration’s offsets are always “now” — there is no cross-revision anchor wrapper to translate through, because the positions are re-based the instant the text changes. The store is a delta-gap interval SumTree (DecoItem = gap + len; the relative-coordinate DecoSummary carries a rebasing max_end): windowed queries are an O(log n) interval descent, and the eager mover shifts a whole suffix in O(edit-window + log n) by rewriting one seam gap — never the O(store) per-commit rescan a flat Vec would force at find scale (10k matches).

Stickiness is a named pair of Biases, one per boundary marker (“sticks to the previous char?”); the mover threads each endpoint through Patch::map_offset with that boundary’s bias and never inverts — a range may collapse to empty, but its start never passes its end.

One file, one owner: this module owns the store and its mover only. The squiggle drawing (squiggle_vertices, SquiggleContext, default_squiggle_style) is the iced layer’s concern and lives in scrive-iced/src/squiggle.rs — nothing here touches pixels or colors. The store’s methods live on a standalone DecorationStore so this module is self-contained; Document wires the store in and drives its mover.

Structs§

DecorationId
A decoration’s identity: monotonic, never reused within a store’s lifetime.
DecorationStore
The tracked-range decoration store: the one store, one mover.
Diagnostic
One compiler finding as published by the app’s debounced compile loop — the unified diagnostic type.
TrackedRange
One tracked range: a DecorationId, a current-revision byte Range, its DecorationKind, and its Stickiness.

Enums§

DecorationKind
What a tracked range is. The variant carries every distinction the render path, a diagnostics panel, and a future hover need directly — no separate owner-id or filter machinery alongside it.
DiagnosticsOutcome
The result of publishing a diagnostic set.
EmptyPolicy
What the mover does with a range that collapsed to empty on an edit.
Severity
Diagnostic severity. Ord is the render order: squiggles draw in ascending order so the most severe paints last and wins.
Stickiness
The four stickiness modes, stored as what they are: a named pair of Biases, one per boundary marker.