pub struct Transaction {
pub steps: Vec<EditStep>,
pub cursor_before: Option<Position>,
pub cursor_after: Option<Position>,
}Expand description
A transaction groups one or more edit steps into an atomic operation. Applying a transaction is all-or-nothing. Transactions can be inverted for undo.
Fields§
§steps: Vec<EditStep>§cursor_before: Option<Position>Cursor position before this transaction was applied (for undo restoration).
cursor_after: Option<Position>Cursor position after this transaction was applied.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn with_cursors(self, before: Position, after: Position) -> Self
pub fn with_cursors(self, before: Position, after: Position) -> Self
Set cursor positions for undo/redo.
Sourcepub fn inverse(&self) -> Self
pub fn inverse(&self) -> Self
Create the inverse transaction (for undo). Steps are reversed and individually inverted. Cursor positions are swapped.
Sourcepub fn can_coalesce(&self, other: &Transaction) -> bool
pub fn can_coalesce(&self, other: &Transaction) -> bool
True if this transaction can be coalesced with another. A single-char insert/delete can merge into an existing run if it continues at the expected position. Newlines break coalescing.
Sourcepub fn merge(&mut self, other: &Transaction)
pub fn merge(&mut self, other: &Transaction)
Merge another transaction into this one (for coalescing).
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
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
Mutably borrows from an owned value. Read more