Expand description
Multibuffers: one buffer composed of excerpts from other buffers and files, and every concern that comes with them.
A dedicated crate since M.2.b.1 (2026-05-31). Lives outside
lattice-runtime so that:
- The runtime crate stays focused on the actor + handle + Document-trait substrate; multibuffer is one specific kind of document built on top of that substrate, not part of it.
- Plugins (post-v1) can depend on
lattice-multibufferdirectly without pulling in the full actor machinery. - The crate boundary makes the design self-documenting —
every multibuffer concern is in one tree; nothing else
knows multibuffer exists except
lattice-host’s tiny boot-wiring registration.
See docs/dev/architecture/multibuffer-views.md §3.6 for the
crate-layout decision.
§What this crate ships (M.2.b.1)
- Data model:
Excerpt,ExcerptId,ExcerptHeader,ExcerptHeaderStyle,RowEntry,RowTranslation. - Handle:
MultibufferDocumentHandle— read-only impl oflattice_runtime::Documentcomposing N source handles into one view. M.3 lifts the read-only restriction. - Header provider:
MultibufferExcerptHeaderProvider(impllattice_cells::VirtualRowProvider) emitting one virtual row per excerpt header.
§What lands later
- M.2.b.2 —
MultibufferModeas the major mode forBufferKind::Multibuffer. Activation owns the header provider registration + per-buffer typed context Guard. - M.2.b.3 —
]e/[e/]E/[Emotions registered through the grammar; bound inMultibufferModekeymap. - M.3 — edit propagation (writes flow back to source handles via the row translation).
- M.4 — live updates from sources (auto-recompose on
EventKind::DocumentChanged; anchor sliding; source-close auto-remove). - M.5–M.8 — expand-context, provider trait + first consumer, fold providers.
Re-exports§
pub use crate::events::MultibufferExcerptsReady;pub use crate::install::install;pub use crate::mode::MultibufferMode;pub use crate::mode::register_multibuffer_ex_commands;pub use crate::mode::register_multibuffer_modes;pub use crate::motions::MultibufferMotionIds;pub use crate::motions::register_multibuffer_motions;pub use crate::registry::InMemoryMultibufferRegistry;pub use crate::registry::MultibufferRegistry;pub use crate::registry::MultibufferRegistryHandle;pub use crate::view::create_multibuffer_view;
Modules§
- events
- Crate-level multibuffer events.
- install
- BC.7 (2026-06-24): the crate-owned
install(boot)entry point. - mode
- M.2.b.2 (2026-06-01):
MultibufferMode— the major mode bound toBufferKind::Multibuffervia H.2’sMode::target_buffer_kinddeclaration. - motions
- M.2.b.3 (2026-06-01): excerpt-jump motions.
- providers
- M.6 (2026-06-01) onwards: in-tree multibuffer providers.
- registry
- M.2.b.2 (2026-06-01): typed handle lookup for multibuffer views.
- view
- M.2.b.2 (2026-06-01):
create_multibuffer_view— the atomic “make me a multibuffer view” entry point that providers (and tests) call.
Structs§
- Excerpt
- One excerpt of a source document, identified by its source
BufferIdand an inclusive line range[start_line, end_line]. - Excerpt
Fold Provider - M.7: computes one open [
lattice_core::Fold] per excerpt in the composed multibuffer. Registered as a [lattice_core::FoldSource] byMultibufferMode::on_activateviaFoldOverlayService; theFoldSourceAdapterinlattice-hostgatescompute_foldsto calls whereFoldContext::buffer_idmatches this multibuffer’s buffer ID. - Excerpt
Header - Header presentation for an excerpt — title + style + the mode-owned semantic data the rich header renderer reads (MH.A2, see multibuffer-views.md §3.8).
- Excerpt
Id - Unique identity for an excerpt within a multibuffer. Stable for the excerpt’s lifetime; survives reorders / source-edit rebuilds.
- File
Boundary Fold Provider - M.8: computes one open [
lattice_core::Fold] per distinct source [BufferId] (file), spanning the composed-row range from the first to the last excerpt belonging to that file. Registered alongsideExcerptFoldProviderbyMultibufferMode::on_activate. Enables collapsing all excerpts from a file to its header row withza. - Header
Group Fold Provider - AF.1: one open [
lattice_core::Fold] per header run — the rows a user sees under one header. - Multibuffer
Document Handle - A multibuffer document handle. Composes N source
Arc<dyn Document>s into one read-only composed view; impls [Document] so dispatch / motion / render code paths serve it the same as a regularRopeDocumentHandle. - Multibuffer
Excerpt Header Provider - Emits one virtual row per excerpt header, anchored above the
excerpt’s first composed row. Cheap-clone reference to the
multibuffer handle; re-reads excerpts on each
collect(). - Multibuffer
Header Element Ids - The interned [
ElementId]s for the excerpt-header elements, captured once at view-creation and held by the provider so eachcollect()is an array-index resolve (resolved.get(id)), never a per-row name lookup.Copy; cheap to thread through. - Multibuffer
Headerline Changed - M.4 (2026-06-01): published whenever a view’s headerline
status changes. Renderers + status-line consumers subscribe
via
EventBus::subscribe_typed::<MultibufferHeaderlineChanged>. - Multibuffer
Source Closed - M.4 (2026-06-01): published when one of a multibuffer’s source buffers closes. Providers subscribe to choose a source-close policy: project-search drops the stale excerpts; project-diff may keep them as historical reference. Multibuffer itself prunes the source from its internal map.
- Multibuffer
Source Edited - PD.7c: published when one of a multibuffer’s source buffers is
edited — the peer of
MultibufferSourceClosed, and it exists for the same reason. - Multibuffer
Status Provider - Sticky headerline provider that surfaces the view’s
HeaderlineStatusas a pinned row above line 0. - RowTranslation
- Composed-row → source-row mapping. One entry per composed row, in display order. Rebuilt on every recompose.
Enums§
- Excerpt
Header Style - Style discriminator for excerpt headers. M.2 shipped a single
Defaultvariant and said future ones would distinguish header presentation; MH.A6 adds the first. - Fold
Grouping - AF.1: how a multibuffer view’s rows group for folding.
- Headerline
Status - View-level headerline status. Rendered above the first
excerpt (M.2.a
MultibufferExcerptHeaderProviderextends to handle the view header in a later renderer slice). - Multibuffer
Error - RowEntry
- One row in the composed multibuffer view, mapped back to its source.
Constants§
- ELEM_
EXCERPT_ HEADER - Element name: the excerpt-header row’s backdrop (a neutral
surface tint, distinct from the diff-deletion-block red the
renderer would otherwise fall a
bg: NoneGeneric row through to). - ELEM_
EXCERPT_ HEADER_ COUNT - Element name: the excerpt-header match-count foreground.
- ELEM_
EXCERPT_ HEADER_ EMPHASIS - Element name: the emphasised excerpt-header row’s backdrop.
- ELEM_
EXCERPT_ HEADER_ EMPHASIS_ TITLE - Element name: the emphasised excerpt-header’s title foreground.
- ELEM_
EXCERPT_ HEADER_ PATH - Element name: the excerpt-header file-path / title foreground.
- ELEM_
STATUS_ COMPLETE - Element name: the completed status row foreground (green).
- ELEM_
STATUS_ FAILED - Element name: the failed status row foreground (red).
- ELEM_
STATUS_ IN_ PROGRESS - Element name: the in-progress status row foreground (neutral grey).
- ELEM_
STATUS_ QUERY - Element name: the emphasised-term foreground (accent) — e.g. the project-search query woven into the status label.
Functions§
- compose_
header_ rows - Pure function from excerpt list → header virtual rows, under
grouping. - default_
header_ cells - Default header-rendering:
── <title> ──(box-drawing rules). Empty title yields a row of box rules only. - multibuffer_
excerpt_ header_ provider_ id - multibuffer_
expand_ excerpt_ at - M.10.4 (2026-06-03): host glue for the
:multibuffer-expand [n]/:multibuffer-contract [n]ex-commands. Looks up the active buffer’s typedMultibufferDocumentHandlevia theMultibufferRegistryHandleservice and callsexpand_excerpt_at(cursor_row, delta). No-op when the active buffer isn’t a multibuffer view, the service isn’t registered (test harness), or the cursor is out of range. - multibuffer_
status_ provider_ id - register_
multibuffer_ theme_ elements - Register the multibuffer mode’s theme elements against
reg. Idempotent by name (safe to call on every mode activation / every view creation). Returns the interned [ElementId]s the excerpt-header provider bakes from.