Skip to main content

DispatchEnv

Struct DispatchEnv 

Source
pub struct DispatchEnv {
Show 18 fields pub scope_resolver: Option<ScopeResolverHandle>, pub comment_syntax: Option<Arc<CommentSyntax>>, pub syntax: Option<Arc<dyn Any + Send + Sync>>, pub indent: IndentUnit, pub indent_resolver: Option<IndentResolverHandle>, pub textwidth: WrapWidth, pub native_format: NativeFormatIntents, pub selection: Option<Range>, pub last_find: Option<LastFind>, pub fold_resolver: Option<FoldResolverHandle>, pub last_search: Option<LastSearch>, pub marks: Option<MarkResolverHandle>, pub viewport: Option<ViewportResolverHandle>, pub nostartofline: bool, pub scrolloff: u32, pub curswant: Option<Curswant>, pub display: Option<DisplayResolverHandle>, pub curswant_out: Option<Arc<Mutex<Option<Curswant>>>>,
}
Expand description

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 apply may read — the tree-sitter scope_resolver (af/ac, N.1.4) and the comment_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 a lattice_grammar::GrammarEnv at the execute_with_env call. Default is the no-input case.

Fields§

§scope_resolver: Option<ScopeResolverHandle>§comment_syntax: Option<Arc<CommentSyntax>>§syntax: Option<Arc<dyn Any + Send + Sync>>

OT.4: the buffer’s tree-sitter snapshot, type-erased so lattice-runtime stays syntax-free (the plugin trampoline downcasts it back to an Arc<SyntaxSnapshot>).

Distinct from scope_resolver rather than replacing it, and the distinction is why this field had to exist. The resolver answers “what scope encloses this point” for the NATIVE structural objects and is deliberately erased to that one question — the concrete snapshot cannot be recovered from it, so it cannot mint a plugin’s tree-snapshot resource.

TS.1 left this out because grammar actions were the only tree-snapshot consumer, and those dispatch through the host’s Action gate rather than this channel. OT.1 made motions and text objects consumers too, and they come through here — so without this field org’s ar / ]] / g{ received none on every real keystroke while every test that built a GrammarEnv by hand passed.

§indent: IndentUnit

IN.0: one level of indentation, resolved by the host from shiftwidth / expandtab / tabstop. Read by > / <. Default is the registered option defaults, so the actor path indents like an unconfigured buffer rather than not at all.

§indent_resolver: Option<IndentResolverHandle>

IN.7: per-line indent depth for =. None means no structural source, and = reindents nothing rather than guessing.

§textwidth: WrapWidth

RF.2: the buffer’s textwidth, for the reflow operator. Carried here for the reason syntax and selection had to be: gq reaches the grammar through the ACTOR path on every real keystroke, so a field missing here is a field the operator never sees no matter how well the direct path is tested.

WrapWidth, not usize, so this struct keeps its derived Default and still means 80 rather than 0.

§native_format: NativeFormatIntents

RF.5b: which formatting intents this buffer handles natively. Carried for the reason textwidth is: = and gq reach the grammar through the ACTOR path on every real keystroke.

§selection: Option<Range>

OS.2: the active region — the Visual/Select selection extent, or None outside Visual/Select.

Carried here for the reason syntax above had to be: an action reached through the ACTOR path builds its ActionContext from this env, so a hard None would make a plugin’s Visual action see no region on every real keystroke while every test that hand-built a GrammarEnv passed. That is the OT.4 failure verbatim, and it is cheaper to carry the field than to rediscover it.

§last_find: Option<LastFind>

VM.3c: the last f / F / t / T, so ; and , can be motions.

Same reasoning as every field above it: ; is an ordinary motion on the keystroke path, so it comes through the actor, so the state it needs has to travel with the dispatch. None is the pre-first-f state and makes ; a no-op, which is what vim does.

§fold_resolver: Option<FoldResolverHandle>

VM.3i: the fold edges zj / zk step between. Same reasoning as last_find: they’re motions on the keystroke path, so they come through the actor. None for a buffer with no folds.

§last_search: Option<LastSearch>

VM.3d-2: the last search, for n / N / * / #, which are motions on the keystroke path and so come through the actor too.

§marks: Option<MarkResolverHandle>

VM.3e: the mark table, for 'x / `x, which come through the actor like every keystroke motion. None when no mark is set.

§viewport: Option<ViewportResolverHandle>

VM.3f: the lines the window shows, for H / M / L. The host builds it only when the invocation is one of them.

§nostartofline: bool

VM.3f: !startofline — H / M / L keep the cursor’s column.

§scrolloff: u32

VM.3f: scrolloff, the margin H / L stop short of the window’s edges by. 0 puts them on the first and last lines shown.

§curswant: Option<Curswant>

VM.3g-1: vim’s curswant, the column j / k aim for across short lines. Carried like every other keystroke input: j comes through the actor on every press.

§display: Option<DisplayResolverHandle>

VM.3g-2: display geometry for gj / gk / g0 / g$, built only when the invocation is one of them.

§curswant_out: Option<Arc<Mutex<Option<Curswant>>>>

VM.3g-3: where a motion reports the goal column it AIMED at, which for gj / gk is not the column it reached — the display row it lands on may be too short, and vim keeps the aim (measured: a clamped gj landing at column 100 records curswant 160).

Owned rather than borrowed, unlike its GrammarEnv counterpart, and that is forced rather than chosen: this struct crosses the Document trait into a Pending<Effect>, so a borrow could not outlive the future. The actor borrows it back out at the execute_with_env call, which is the same shape every other field here already has.

None — the default — discards the report, which is right for every caller that keeps no goal column.

Trait Implementations§

Source§

impl Clone for DispatchEnv

Source§

fn clone(&self) -> DispatchEnv

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for DispatchEnv

Source§

fn default() -> DispatchEnv

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more