Skip to main content

Module command

Module command 

Source
Expand description

Normal-mode command resolution independent of key bindings.

MotionState owns only state that is required to turn a motion template into a completed Motion: a saturating decimal count, a pending f/F/ t/T character argument, and the last completed character search used by ; and ,. It does not own terminal events, multi-key mapping timeouts, search queries, marks, jump lists, buffers, cursors, or viewports.

A caller normally feeds count digits to MotionState::push_count_digit, passes a bound motion to MotionState::finish, and, after MotionResolution::AwaitingTarget, routes the next eligible character to MotionState::accept_target. Mode/focus changes should call MotionState::reset_pending so an incomplete command cannot leak into a different input context. The last completed character search intentionally survives that reset.

§Example

use vim_navigation::command::{MotionResolution, MotionState};
use vim_navigation::motion::{Motion, MotionKind};

let mut state = MotionState::new();
assert!(state.push_count_digit('3'));
let MotionResolution::Ready(motion) =
    state.finish(Motion::new(MotionKind::Right))
else {
    panic!("a non-targeted motion is immediately ready");
};
assert_eq!(motion.count(), 3);

Structs§

MotionState
Normal-mode state shared across configurable key adapters.

Enums§

MotionResolution
The result of submitting a motion template to MotionState.