pub enum Edit {
InsertChar {
at: Position,
ch: char,
},
InsertStr {
at: Position,
text: String,
},
DeleteRange {
start: Position,
end: Position,
kind: MotionKind,
},
JoinLines {
row: usize,
count: usize,
with_space: bool,
},
SplitLines {
row: usize,
cols: Vec<usize>,
inserted_space: bool,
},
Replace {
start: Position,
end: Position,
with: String,
},
InsertBlock {
at: Position,
chunks: Vec<String>,
},
DeleteBlockChunks {
at: Position,
widths: Vec<usize>,
},
}Expand description
One unit of buffer mutation. Constructed by the caller (vim
engine, ex command, …) and handed to Buffer::apply_edit.
Variants§
InsertChar
Insert one char at at. Cursor lands one position past it.
InsertStr
Insert text (possibly multi-line) at at. Cursor lands at
the end of the inserted content.
DeleteRange
Delete [start, end) with the given kind.
JoinLines
J (with_space = true) / gJ (false) — fold count rows
after row into row.
SplitLines
Inverse of JoinLines. Splits row back at each char column
in cols. inserted_space matches the original join so the
inverse can drop the space before splitting.
Replace
Replace [start, end) with with (charwise, may span rows).
InsertBlock
Insert one chunk per row, each at (at.row + i, at.col).
Inverse of a blockwise delete; preserves the rectangle even
when rows are ragged shorter than at.col.
DeleteBlockChunks
Inverse of Edit::InsertBlock. Removes widths[i] chars
starting at (at.row + i, at.col). Carrying widths instead
of recomputing means a ragged-row block delete round-trips
exactly.
Trait Implementations§
impl Eq for Edit
impl StructuralPartialEq for Edit
Auto Trait Implementations§
impl Freeze for Edit
impl RefUnwindSafe for Edit
impl Send for Edit
impl Sync for Edit
impl Unpin for Edit
impl UnsafeUnpin for Edit
impl UnwindSafe for Edit
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more