Expand description
SN.2: the live snippet-expansion session, relocated off the host
Editor so the mode-owned placeholder-navigation handlers can
reach it.
While a snippet is expanding, exactly one ActiveSnippet is
live (the tabstop groups + the focused index). Before SN.2 this
lived as Editor.active_snippet: Option<ActiveSnippet> and the
<Tab> / <S-Tab> handlers were Editor::do_snippet_* methods.
Per feedback_mode_owns_its_surface, the handler bodies belong to
the mode that owns the chords (SnippetActiveMode). The
ActionHandlerRegistry seam hands a handler only an
ActionContext (no &mut Editor),
so the session it mutates must live somewhere both the host (which
still creates the session on expand — SN.3 moves that too) and the
mode handler can reach: this service, registered in the
ServiceRegistry under SnippetSessionHandle.
SN.3e: the session is keyed by buffer
(HashMap<BufferId, ActiveSnippet>), not a single global slot.
Before SN.3e a snippet started in buffer A then switching to B lit
active-snippet-mode on B and routed <Tab> to A’s tabstops
against B’s cursor (the predicate + slot were buffer-agnostic).
Snippet state is buffer-local (everything-is-a-buffer ⇒ per-buffer,
not a singleton), so every operation names its buffer: handlers use
core_buffer_id(ctx.buffer_id), host paths use the document buffer.
One Mutex guards the map. Snippet operations are rare (per
<Tab>, never per render), so the lock is uncontended and off any
hot path.
Structs§
- Snippet
Session - The live snippet sessions, keyed by the buffer each is expanding in (a buffer is absent from the map when no snippet is live there).
Functions§
- snippet_
active_ predicate - Predicate for the host’s generic session-backed-minor
reconciler:
active-snippet-modeshould be active on the active buffer exactly while a snippet session is live. The host pairs this withSnippetActiveMode::mode_id()at boot and reconciles it each overlay-sync cycle — so the host’s generic sync carries nosnippet_session.is_active()literal. Keeps the “when is my mode active?” policy in this crate perfeedback_mode_owns_its_surface.
Type Aliases§
- Snippet
Session Handle - Shared handle, registered in
ServiceRegistryand held by the host. Perfeedback_servicesregistry_arc_typeid: register and look up under this exact alias so theTypeIdmatches.