Skip to main content

Module folding

Module folding 

Source
Expand description

Buffer-level folding semantics.

M.7 adds FoldSource + FoldOverlayService — a dep-safe bridge that lets subsystems below lattice-host (e.g. lattice-multibuffer) register overlay fold providers without depending on FoldContext or FoldProvider.

FoldMethod decides which provider feeds the per-buffer fold list. Fold is the per-range entry the list holds. Both are renderer-agnostic: a fold is just (start_line, end_line, closed, identity); the gutter glyph + summary-line text are rendering concerns layered on top.

Structs§

Fold
One contiguous fold range in a document buffer.
ProviderId
Stable identifier for a registered fold provider. Two distinct providers must produce distinct ids; a single provider produces the same id across recomputes. Used by the registry for lookup and by diagnostics that need to attribute a fold back to its source.

Enums§

FoldMethod
:set foldmethod=... (DESIGN.md §15:18, C.2; docs/user/folding.md). Decides which provider feeds the per-buffer fold list.
ProviderKind
Distinguishes mutually-exclusive primary fold sources (one runs at a time, picked by :set foldmethod=) from additive overlay sources (always compose). See docs/dev/architecture/fold-architecture.md §2.

Traits§

FoldOverlayService
Service for registering / deregistering overlay fold sources. Implemented by FoldOverlayServiceImpl in lattice-host (which wraps Arc<Mutex<FoldRegistry>>). Registered in the ServiceRegistry at boot so MultibufferMode::on_activate can call add_source without depending on lattice-host.
FoldSource
Data-only fold source for subsystems that live below lattice-host (e.g. ExcerptFoldProvider in lattice-multibuffer). Implementors cannot depend on FoldContext or FoldProvider (both defined in lattice-host). FoldSourceAdapter in lattice-host::fold_provider wraps any FoldSource as a FoldProvider by delegating compute() to compute_folds and ignoring FoldContext.

Type Aliases§

FoldOverlayServiceHandle
Cheap-clone handle for the fold-overlay service. Mode guards hold one Arc so they can call remove_source on Drop.