Skip to main content

VimSessionState

Struct VimSessionState 

Source
pub struct VimSessionState {
Show 14 fields pub pending_motion: Option<PendingMotion>, pub pending_textobj_range: Option<TextObjRange>, pub pending_char: Option<PendingCharOp>, pub pending_count: Option<usize>, pub pending_register: Option<char>, pub last_change: Option<LastChange>, pub insert_buffer: String, pub recording_register: Option<char>, pub recording_keys: Vec<KeyEvent>, pub last_macro_register: Option<char>, pub macro_playback_depth: usize, pub recording_repeat: bool, pub repeat_keys: Vec<KeyEvent>, pub replace_restore_stack: Vec<ReplaceRestoreEntry>,
}
Expand description

Vim-specific per-session state.

Stored via SessionExtension, accessed by vim resolvers and commands. Each client session has its own independent vim state.

§Note on Operators (Epic #415)

Operator state (d, y, c) is owned by dedicated mode resolvers, not here. See VimDeleteResolver, VimYankResolver, VimChangeResolver.

Fields§

§pending_motion: Option<PendingMotion>

Pending motion info (Epic #415, Issue #388).

When the operator resolver dispatches a motion, it stores the motion type here. After the motion executes, on_command_complete uses this to complete the operator with the correct linewise flag.

This replaces CommandResult::Motion - motion type is resolver policy, not command mechanism.

§pending_textobj_range: Option<TextObjRange>

Pending text object range (Epic #465).

When a text object command executes during operator-pending mode, it stores the calculated range here. The operator resolver’s on_command_complete consumes this range via take().

Text object range takes priority over motion-based range calculation.

§pending_char: Option<PendingCharOp>

Pending character operation (f, F, t, T, r).

When a user presses a character-wait command, the operation type is stored here until the next character is typed.

§pending_count: Option<usize>

Numeric prefix accumulator.

When digits are pressed before a command (e.g., 5j), the count is accumulated here.

§pending_register: Option<char>

Register selection (e.g., "a sets register to ‘a’).

When a register prefix is typed, the register is stored here until the next operator/command uses it.

§last_change: Option<LastChange>

Last change for dot repeat (Epic #465).

Set by operator resolvers after completing an operation, and by insert mode exit. Used by the . command to replay the last change.

§insert_buffer: String

Insert mode text accumulator.

Tracks characters inserted during insert mode. Cleared on insert mode entry, recorded as LastChange::Insert on insert mode exit.

§recording_register: Option<char>

Currently recording macro to this register (None = not recording).

When set, all keys processed by the normal resolver are accumulated in recording_keys. Set by q{a-z}, cleared by q (stop recording).

§recording_keys: Vec<KeyEvent>

Accumulated keys during macro recording.

Cleared when recording starts, stored to register when recording stops. The final q key that stops recording is NOT included.

§last_macro_register: Option<char>

Last played macro register (for @@ repeat).

Updated each time a macro is played with @{a-z}.

§macro_playback_depth: usize

Current macro playback depth (for recursion detection).

Incremented when a macro starts playing, decremented when it finishes. Playback is blocked when depth reaches MAX_MACRO_DEPTH (16).

§recording_repeat: bool

Whether we are currently recording keys for dot repeat.

Set when an operator or insert-entry command starts, cleared when the change completes. Independent from macro recording — both can be active simultaneously.

§repeat_keys: Vec<KeyEvent>

Accumulated key sequence during the current change.

Cleared when recording starts, saved into last_change.keys when recording finishes. Used by . to replay the exact key sequence.

§replace_restore_stack: Vec<ReplaceRestoreEntry>

Restore stack for replace mode backspace.

Each entry records the position and original character that was overwritten. Backspace pops from this stack to restore the original. Cleared on replace mode entry.

Implementations§

Source§

impl VimSessionState

Source

pub fn is_pending(&self) -> bool

Check if there is any pending state.

Returns true if any vim operation is waiting for input.

§Note (Epic #415)

This no longer checks pending_operator - the dedicated operator resolvers (DELETE, YANK, CHANGE) own their state directly.

Source

pub const fn is_recording(&self) -> bool

Check if currently recording a macro.

Source

pub const fn is_macro_depth_exceeded(&self) -> bool

Check if macro playback would exceed depth limit.

Source

pub fn clear_pending(&mut self)

Clear all pending state.

Called when an operation is cancelled (e.g., pressing Escape).

§Note (Epic #415)

Operator state (d, y, c) is managed by dedicated mode resolvers (VimDeleteResolver, VimYankResolver, VimChangeResolver), not by this method.

§Note (Epic #465)

last_change is NOT cleared here - it persists until the next change operation so dot repeat can replay it.

Source

pub fn take_count(&mut self) -> usize

Get the effective count, defaulting to 1 if not set.

Takes the pending count, clearing it in the process.

Source

pub fn take_register(&mut self) -> Option<char>

Get the register, clearing it in the process.

Returns None if no register was selected (use default register).

Source

pub fn start_recording(&mut self, register: char) -> bool

Start recording a macro to the given register.

Clears any previously recorded keys and sets the recording register. Returns false if the register name is invalid (not a-z).

Source

pub fn stop_recording(&mut self) -> Option<(char, Vec<KeyEvent>)>

Stop recording and return the recorded keys.

Returns None if not currently recording. The caller is responsible for storing the keys in the register.

Source

pub fn record_key(&mut self, key: KeyEvent)

Record a key during macro recording.

Does nothing if not currently recording.

Source

pub fn start_repeat_recording(&mut self)

Start recording keys for dot repeat.

Called when an operator or insert-entry command begins a change. Clears any previously accumulated keys and sets the recording flag.

Source

pub fn record_repeat_key(&mut self, key: KeyEvent)

Record a key for dot repeat.

Does nothing if not currently recording for repeat.

Source

pub fn finish_repeat_recording(&mut self)

Finish recording and save keys into last_change.

Copies the accumulated repeat_keys into last_change.keys and clears the recording flag. If last_change is None, does nothing (the caller should have set last_change before calling this).

Source

pub fn enter_macro_playback(&mut self) -> bool

Enter macro playback (increment depth counter).

Returns false if depth limit would be exceeded.

Source

pub fn exit_macro_playback(&mut self)

Exit macro playback (decrement depth counter).

Trait Implementations§

Source§

impl Debug for VimSessionState

Source§

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

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

impl Default for VimSessionState

Source§

fn default() -> VimSessionState

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

impl SessionExtension for VimSessionState

Source§

fn create() -> Self

Create default state for a new session. Read more
Source§

fn as_text_input_sink(&mut self) -> Option<&mut dyn TextInputSink>

Return self as a TextInputSink if this extension accepts text input. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> SessionExtensionDyn for T

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Get as &dyn Any for downcasting.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Get as &mut dyn Any for mutable downcasting.
Source§

fn as_text_input_sink(&mut self) -> Option<&mut dyn TextInputSink>

Get as TextInputSink if this extension accepts text input.
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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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