Expand description
M.0 (2026-05-31): Document trait — the handle-layer
abstraction over a buffer that the rest of the editor talks
to.
Today’s RopeDocumentHandle (a rope-backed actor handle) impls
this trait; M.1 lands MultibufferDocumentHandle as a sibling
impl composing N source handles. Dispatch / motion / render
code paths hold Arc<dyn Document> so they serve both kinds
without kind-branching at the buffer boundary.
See docs/dev/architecture/multibuffer-views.md §3.1 for the
design and the Path-A/B/C alternatives that were considered
and rejected.
§Slot replacement is the only path
There is intentionally no replace(...) method on this trait.
Per the M.0 design (§3.1 “Why no replace”), “the active
document changes” is expressed by replacing the slot’s
Arc<dyn Document> with a freshly spawned handle, not by
mutating the existing handle in place. The old handle drops
when its last Arc reference goes away; the actor task exits
cleanly through its mailbox-close branch. One uniform code
path for :edit foo / :edit bar / regular ↔ multibuffer
transitions / :b N switches.
§Object safety
Trait is dyn-safe: Arc<dyn Document> is the canonical
reference shape. All methods take &self (writes return
Pending<T> which round-trips the impl’s internal write
path — actor mpsc for RopeDocumentHandle, fan-out for
MultibufferDocumentHandle).
Most read methods carry default implementations derived from
snapshot() so impls only need to provide snapshot() plus
the write methods. MultibufferDocumentHandle may override
text() if it can compose more cheaply than snapshot() .text().
Structs§
- Active
Document - M.0 (2026-05-31): the active-document slot held by
Editor.document. Wraps anArc<dyn Document>so that: - Dispatch
Env - N.1.6 (2026-06-10): the owned, thread-safe per-dispatch environment
for text objects, carried across the actor channel. Bundles the
inputs a text object’s
applymay read — the tree-sitterscope_resolver(af/ac, N.1.4) and thecomment_syntax(aC/iC, N.1.6) — so the dispatch seam threads ONE value instead of a widening parameter list (the long-term-fit choice over parallel params). The actor borrows these into alattice_grammar::GrammarEnvat theexecute_with_envcall.Defaultis the no-input case.
Traits§
- Document
- Handle-layer abstraction over a buffer. See module docs.
Type Aliases§
- Display
Resolver Handle - VM.3g-2: owned display geometry for
gj/gk/g0/g$. - Fold
Resolver Handle - VM.3i: the same handle convention for
zj/zk’s fold edges. The host builds one from its fold table for a dispatch; the grammar sees a bare&dyn FoldResolver. - Indent
Resolver Handle - IN.7: the same handle convention for the
=operator’s per-line indent source. Owned +Send + Syncso it can cross the actor channel; the grammar side sees a bare&dyn IndentResolver. - Mark
Resolver Handle - VM.3e: owned mark table for
'x/`x, likeFoldResolverHandle. - Scope
Resolver Handle - N.1.4b (2026-06-10): a sharable, thread-safe scope resolver
handle threaded through grammar dispatch. The host wraps the
active document’s
Arc<SyntaxSnapshot>(which implslattice_grammar::ScopeResolver) in this alias, bundles it into aDispatchEnv, and passes it toDocument::dispatch_with_env; the actor hands it toexecute_with_envso tree-sitter text objects (af/ac/aa/al) resolve against the live tree.Send + Syncbecause the actor message crosses the dispatch channel onto the document-actor thread. The bareScopeResolvertrait lives inlattice-grammar(tree-sitter-agnostic); this threading-layer alias adds theArc + Send + Syncshape per the handle convention (cf.CommandRegistryHandle). - Viewport
Resolver Handle - VM.3f: owned window lines for
H/M/L, likeFoldResolverHandle.