pub struct ChangeBank {
pub last_edit: Option<(usize, usize)>,
pub list: Vec<(usize, usize)>,
pub cursor: Option<usize>,
pub u_line: Option<(usize, String)>,
pub last_edit_end: Option<(usize, usize)>,
}Expand description
Per-buffer changelist bank: g;/g, history plus the '. / `.
“last change” mark. Shared via Arc<Mutex<ChangeBank>> across every
window’s Editor viewing the SAME buffer — vim’s changelist and
last-change mark are per-buffer, not per-window, so an edit made in one
split must be visible to g; / `. from any other split on that
buffer (audit B3).
UNLIKE GlobalMarks / [Registers] / SearchBank / abbrevs /
last-substitute — which are each a single Arc shared by literally
every Editor in the app, session-global — a ChangeBank is
per-buffer: the app layer keys a bank per buffer_id and hands each
Editor the Arc for its CURRENT buffer, swapping it whenever the
editor’s buffer changes (see App::change_bank_for /
Editor::set_change_bank_arc). Two editors on the same buffer_id share
one bank; editors on different buffers never see each other’s entries.
Fields§
§last_edit: Option<(usize, usize)>Position of the most recent buffer mutation, matching vim’s :h '.
(“the position where the last change was made” — change-start, not
the post-edit cursor). Surfaced via the '. / `. marks.
list: Vec<(usize, usize)>Bounded ring of recent edit positions (newest at back). g; walks
toward older, g, toward newer. Capped at
crate::types::CHANGE_LIST_MAX.
cursor: Option<usize>Index into list while walking; None outside a walk (any new
edit clears it and trims forward entries).
u_line: Option<(usize, String)>U (:h U) bookkeeping: (row, text) — the text of row before
the first change landed on it since the tracked row last
changed. Reset (row + fresh snapshot) whenever an edit’s pre-edit
cursor row differs from the currently tracked row.
Editor::undo_line swaps this to the pre-U text on each call
so a second U redoes what the first one undid.
last_edit_end: Option<(usize, usize)>Post-edit cursor position of the most recent mutate_edit call —
NOT part of any undo/redo snapshot (deliberately: after an undo/
redo this goes stale and the next edit correctly starts a fresh
burst). Lets mutate_edit tell whether the next edit is a
continuation of the same typing burst (its pre-edit position
picks up exactly where this one left the cursor) or the start of
a new one — see the entry comment in mutate_edit for why this
matters for g; / `.: a whole AXYZ<Esc> insert session is
ONE vim change, not three, and g; from a fresh cursor lands on
its start column, not the last-typed character’s.
Trait Implementations§
Source§impl Clone for ChangeBank
impl Clone for ChangeBank
Source§fn clone(&self) -> ChangeBank
fn clone(&self) -> ChangeBank
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more