Skip to main content

Module wasm_context

Module wasm_context 

Source
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:

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§

ContextScopeCache
Per-buffer cache of a context plugin’s structural scopes.
WasmContextState
The Editor’s cohesive WASM-context wiring. Bundled into one field so the boot struct literal grows by a single line. Every field defaults, so Editor::default() test fixtures get an inert context seam.

Functions§

store_if_current
TC.13: cache scopes for buffer_id unless a NEWER parse’s answer is already there. Returns whether the write happened.