Expand description
TC.3a — WASM sticky context: producer → per-buffer scope cache → resolver.
The sibling of wasm_decorations, and it exists
for the same reason: a plugin’s producer runs OFF the render path (paramount
goal #1) and the rest of the editor reads only a native cache. What differs
is the staleness key, and the difference is the whole point of the design.
Decorations are per-line marks keyed on the document version. Scopes are
a pure function of the parse tree, so they are keyed on the syntax
snapshot’s version instead. A cursor move, a scroll, or an edit whose reparse
has not landed yet all leave the cached scopes valid — which is what keeps
the producer off the keystroke path entirely. Per-pane resolution
(resolve_context) then runs
natively at cursor rate against this cache.
This module owns:
ContextScopeCache— the per-buffer cache value (the scopes + the parse version they were produced against).WasmContextState— the bundle theEditorholds as one field.Editor::maybe_refresh_wasm_context— the per-tick refresh pump.
The producer trait + registry live in lattice-mode
(AsyncContextSource) so this crate
never depends on lattice-plugin-host. The loader (drain_context)
registers the WASM producer; the host reads it here.
Design: docs/dev/architecture/treesitter-context.md.
Structs§
- Context
Scope Cache - Per-buffer cache of a context plugin’s structural scopes.
- Wasm
Context State - The
Editor’s cohesive WASM-context wiring. Bundled into one field so the boot struct literal grows by a single line. Every field defaults, soEditor::default()test fixtures get an inert context seam.
Functions§
- store_
if_ current - TC.13: cache
scopesforbuffer_idunless a NEWER parse’s answer is already there. Returns whether the write happened.