Skip to main content

MotionResult

Struct MotionResult 

Source
pub struct MotionResult {
    pub target: Position,
    pub linewise: bool,
    pub exclusive: Option<bool>,
    pub notice: Option<MotionNotice>,
    pub curswant: Option<Curswant>,
}
Expand description

What a motion’s evaluator returned.

Fields§

§target: Position

Where the cursor lands.

§linewise: bool

true if the motion is linewise (ranges expand to whole lines on resolution).

§exclusive: Option<bool>

VM.3c: override MotionSpec::exclusive for THIS invocation. None — the overwhelming default — means “use the spec’s flag”.

§Why the axis had to move

linewise has always travelled with the RESULT and exclusive with the SPEC, and nothing needed the asymmetry resolved until a motion existed whose exclusivity is not knowable until it runs. ; is that motion: it repeats whatever f / F / t / T came last, and vim gives it that motion’s exclusivity — f and t are inclusive, F and T are not. A single flag on the ; spec has to be wrong half the time, and it was: d, after an f deleted one character too many, because , acts as F while the spec said inclusive.

Not on the WIT boundary. A plugin declares exclusivity on its MotionSpec, which is the right place for every motion that knows its own answer, so from_wit decodes this as None deliberately rather than for want of a field to read.

§notice: Option<MotionNotice>

VM.3d-2: a notice for the user, which the dispatcher echoes alongside the motion’s effect — the search wrap. Not on the WIT boundary: a plugin motion reports none.

§curswant: Option<Curswant>

VM.3g-3: override the goal column for THIS invocation, the way Self::exclusive overrides the spec’s flag. None — the overwhelming default — means “apply the spec’s CurswantEffect”.

§Why a motion has to be able to say it

CurswantEffect can express “keep the goal”, “pin it to the line end” and “take it from where I landed”, and for every motion in vim except two that is the whole story. gj / gk are the exception: they aim at a screen column that the reached display row may be too short to hold, and vim records the aim, not the landing.

Measured in vim 9.2 (vimcheck_scroll_curswant.vim), wrap at 80 over a 240-char line then a 100-char line:

gj -> line 2 row 1            col=80   curswant=80
gj -> line 2 row 2 (CLAMPED)  col=100  curswant=160

160 is the column the motion wanted — next_start + goal, before the clamp to the row’s 100 characters. Recording the landing instead loses the aim permanently, so a following j onto a long line returns to 100 where vim returns to 160.

SetFromTarget cannot express this because the target IS the clamped landing, and Keep cannot because the goal genuinely changes on every gj (it tracks the screen column down the wrapped rows). Only the motion knows the unclamped aim, so only the motion can report it.

Not on the WIT boundary, for the same reason exclusive is not: a plugin motion declares its effect on the spec, which is the right place for every motion that knows its own answer. from_wit decodes this as None deliberately rather than for want of a field to read.

Trait Implementations§

Source§

impl Clone for MotionResult

Source§

fn clone(&self) -> MotionResult

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 Copy for MotionResult

Source§

impl Debug for MotionResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MotionResult

Source§

fn default() -> MotionResult

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