pub struct TextObjectContext<'a> {
pub buffer: &'a Buffer,
pub at: Position,
pub count: Count,
pub args: Args,
pub cancel: &'a CancellationToken,
pub scope_resolver: Option<&'a dyn ScopeResolver>,
pub comment_syntax: Option<&'a CommentSyntax>,
pub path: Option<&'a Path>,
pub syntax: Option<&'a Arc<dyn Any + Send + Sync>>,
}Expand description
Context passed to a text-object’s evaluator.
Fields§
§buffer: &'a BufferThe buffer text the object reads.
at: PositionThe cursor the object is evaluated around.
count: CountThe count, 1 when none was typed (2aw, 2i().
args: ArgsThe object’s own arguments.
cancel: &'a CancellationTokenCooperative cancellation handle (DESIGN.md §5.2.5). Most
text objects are O(line); polling rarely matters. Tag /
paragraph / sentence objects that walk further can poll
cancel.check()? on their inner loops.
scope_resolver: Option<&'a dyn ScopeResolver>N.1.4a: tree-sitter scope resolver for the structural text
objects (af / ac / …), injected by the host (backed by the
buffer’s SyntaxSnapshot). None for buffers with no syntax —
the structural objects then resolve nothing; the classic
objects (iw, ap, i{) never read it.
comment_syntax: Option<&'a CommentSyntax>N.1.6: comment-leader descriptor for the comment objects
(aC / iC), injected by the host from the active buffer’s
language. None (or line: None) ⇒ the comment objects resolve
nothing. Only aC / iC read it.
path: Option<&'a Path>OM.6b: the file the object’s buffer is backed by — the borrowed peer of
MotionContext::path, for the same reason.
syntax: Option<&'a Arc<dyn Any + Send + Sync>>OT.1: the type-erased tree-sitter snapshot — the borrowed peer of
MotionContext::syntax, for the same reason, and carrying the same
version-agreement guarantee.
Distinct from scope_resolver above rather than replacing it: the
resolver answers “what scope encloses this point” for the native
structural objects, while this hands a plugin the whole tree to query.
A plugin object resolving a subtree needs the second, not the first.