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: StringInsert 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: usizeCurrent 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: boolWhether 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
impl VimSessionState
Sourcepub fn is_pending(&self) -> bool
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.
Sourcepub const fn is_recording(&self) -> bool
pub const fn is_recording(&self) -> bool
Check if currently recording a macro.
Sourcepub const fn is_macro_depth_exceeded(&self) -> bool
pub const fn is_macro_depth_exceeded(&self) -> bool
Check if macro playback would exceed depth limit.
Sourcepub fn clear_pending(&mut self)
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.
Sourcepub fn take_count(&mut self) -> usize
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.
Sourcepub fn take_register(&mut self) -> Option<char>
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).
Sourcepub fn start_recording(&mut self, register: char) -> bool
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).
Sourcepub fn stop_recording(&mut self) -> Option<(char, Vec<KeyEvent>)>
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.
Sourcepub fn record_key(&mut self, key: KeyEvent)
pub fn record_key(&mut self, key: KeyEvent)
Record a key during macro recording.
Does nothing if not currently recording.
Sourcepub fn start_repeat_recording(&mut self)
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.
Sourcepub fn record_repeat_key(&mut self, key: KeyEvent)
pub fn record_repeat_key(&mut self, key: KeyEvent)
Record a key for dot repeat.
Does nothing if not currently recording for repeat.
Sourcepub fn finish_repeat_recording(&mut self)
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).
Sourcepub fn enter_macro_playback(&mut self) -> bool
pub fn enter_macro_playback(&mut self) -> bool
Enter macro playback (increment depth counter).
Returns false if depth limit would be exceeded.
Sourcepub fn exit_macro_playback(&mut self)
pub fn exit_macro_playback(&mut self)
Exit macro playback (decrement depth counter).
Trait Implementations§
Source§impl Debug for VimSessionState
impl Debug for VimSessionState
Source§impl Default for VimSessionState
impl Default for VimSessionState
Source§fn default() -> VimSessionState
fn default() -> VimSessionState
Source§impl SessionExtension for VimSessionState
impl SessionExtension for VimSessionState
Source§fn as_text_input_sink(&mut self) -> Option<&mut dyn TextInputSink>
fn as_text_input_sink(&mut self) -> Option<&mut dyn TextInputSink>
TextInputSink if this extension accepts text input. Read moreAuto Trait Implementations§
impl Freeze for VimSessionState
impl RefUnwindSafe for VimSessionState
impl Send for VimSessionState
impl Sync for VimSessionState
impl Unpin for VimSessionState
impl UnsafeUnpin for VimSessionState
impl UnwindSafe for VimSessionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> SessionExtensionDyn for Twhere
T: SessionExtension,
impl<T> SessionExtensionDyn for Twhere
T: SessionExtension,
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any for mutable downcasting.Source§fn as_text_input_sink(&mut self) -> Option<&mut dyn TextInputSink>
fn as_text_input_sink(&mut self) -> Option<&mut dyn TextInputSink>
TextInputSink if this extension accepts text input.