pub enum InsertReason {
Enter(InsertEntry),
Open {
above: bool,
},
AfterChange,
DeleteToEol,
ReplayOnly,
BlockEdge {
top: usize,
bot: usize,
col: usize,
pad: bool,
cursor_col: usize,
pre_pad_len: usize,
undo_depth_before: usize,
},
BlockChange {
top: usize,
bot: usize,
col: usize,
},
Replace,
}Variants§
Enter(InsertEntry)
Plain entry via i/I/a/A — recorded as InsertAt.
Open
Entry via o/O — records OpenLine on Esc.
AfterChange
Entry via an operator’s change side-effect. Retro-fills the
stored last-change’s inserted field on Esc.
DeleteToEol
Entry via C (delete to EOL + insert).
ReplayOnly
Entry via an insert triggered during dot-replay — don’t touch last_change because the outer replay will restore it.
BlockEdge
I or A from VisualBlock: insert the typed text at col on
rows in top..=bot. col is the start column for I, the
one-past-block-end column for A.
pad distinguishes the two vim behaviours at rows shorter than
col (:h v_b_I vs :h v_b_A): A pads short rows with spaces
so the appended text still lines up (pad: true); I skips rows
that don’t reach col entirely — no padding, no insert on that
row (pad: false).
cursor_col is where the cursor lands on Esc — the block’s LEFT
edge for both I and A (verified against real nvim: A’s
cursor does NOT land at the append/typed position, col, once
the block is more than one column wide). For I, cursor_col == col (its insertion point already IS the left edge); for A they
differ whenever the block spans more than one column.
Fields
pre_pad_len: usizeTop row’s char count BEFORE the A pad was applied. Recorded at
construction so finish_insert_session can remove exactly the
pad’s bytes (pre_pad_len..col) on an empty Esc — the pad itself
is never recorded as an undo step, so its range must be stashed
here rather than derived from the (already padded) live buffer.
undo_depth_before: usizeUndo-stack depth recorded just before the caller’s push_undo for
this block command. An empty block-A pushes a no-op undo
boundary; when it is still the most recent one (depth == this + 1
at Esc — nothing else pushed mid-session, and the push was not
suppressed by an enclosing undo group), finish_insert_session
consumes it so the no-op command leaves the undo tree untouched.
BlockChange
c from VisualBlock: block content deleted, then user types
replacement text replicated across all block rows on Esc. Cursor
advances to the last typed char after replication (unlike BlockEdge
which leaves cursor at the insertion column).
Replace
R — Replace mode. Each typed char overwrites the cell under
the cursor instead of inserting; at end-of-line the session
falls through to insert (same as vim).
Trait Implementations§
Source§impl Clone for InsertReason
impl Clone for InsertReason
Source§fn clone(&self) -> InsertReason
fn clone(&self) -> InsertReason
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more