pub struct HistoryStack { /* private fields */ }Expand description
Manages undo and redo history with automatic typing burst coalescing.
Implementations§
Source§impl HistoryStack
impl HistoryStack
pub fn new(max_depth: usize) -> Self
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
Sourcepub fn record_insert(
&mut self,
pos: Position,
text: &str,
before_cursors: Vec<Selection>,
after_cursors: Vec<Selection>,
)
pub fn record_insert( &mut self, pos: Position, text: &str, before_cursors: Vec<Selection>, after_cursors: Vec<Selection>, )
Records an insertion with automatic coalescing if typed within 400ms at adjacent position.
Sourcepub fn record_delete(
&mut self,
start: Position,
end: Position,
text: &str,
before_cursors: Vec<Selection>,
after_cursors: Vec<Selection>,
)
pub fn record_delete( &mut self, start: Position, end: Position, text: &str, before_cursors: Vec<Selection>, after_cursors: Vec<Selection>, )
Records a deletion operation.
Sourcepub fn push_transaction(&mut self, tx: EditorTransaction)
pub fn push_transaction(&mut self, tx: EditorTransaction)
Pushes a transaction onto the undo stack, respecting max depth limit.
Sourcepub fn undo(&mut self, buffer: &mut LineBuffer) -> Option<Vec<Selection>>
pub fn undo(&mut self, buffer: &mut LineBuffer) -> Option<Vec<Selection>>
Rolls back the most recent transaction, reversing buffer changes and restoring cursors.
Sourcepub fn undo_with_edits(
&mut self,
buffer: &mut LineBuffer,
) -> Option<(Vec<Selection>, Vec<InputEdit>)>
pub fn undo_with_edits( &mut self, buffer: &mut LineBuffer, ) -> Option<(Vec<Selection>, Vec<InputEdit>)>
Rolls back the most recent transaction and returns both the restored cursors and
the ordered tree_sitter::InputEdit records applied to buffer.
Sourcepub fn redo(&mut self, buffer: &mut LineBuffer) -> Option<Vec<Selection>>
pub fn redo(&mut self, buffer: &mut LineBuffer) -> Option<Vec<Selection>>
Replays the most recently undone transaction.
Sourcepub fn redo_with_edits(
&mut self,
buffer: &mut LineBuffer,
) -> Option<(Vec<Selection>, Vec<InputEdit>)>
pub fn redo_with_edits( &mut self, buffer: &mut LineBuffer, ) -> Option<(Vec<Selection>, Vec<InputEdit>)>
Replays the most recently undone transaction and returns both the restored cursors
and the ordered tree_sitter::InputEdit records applied to buffer.
Trait Implementations§
Source§impl Clone for HistoryStack
impl Clone for HistoryStack
Source§impl Debug for HistoryStack
impl Debug for HistoryStack
Auto Trait Implementations§
impl Forget for HistoryStack
impl Freeze for HistoryStack
impl Move for HistoryStack
impl RefUnwindSafe for HistoryStack
impl Send for HistoryStack
impl Sync for HistoryStack
impl Unpin for HistoryStack
impl UnsafeUnpin for HistoryStack
impl UnwindSafe for HistoryStack
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