Skip to content

Commit

Permalink
UndoManager: undo_stack and redo_stack access methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Horusiath committed Jul 8, 2024
1 parent ab5a889 commit b3f9d92
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion yrs/src/undo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use crate::{DeleteSet, Doc, Observer, Transact, TransactionMut, ID};
/// - [UndoManager::observe_item_popped], which is fired whenever [StackItem] is being from undo
/// manager as a result of calling either [UndoManager::undo] or [UndoManager::redo] method.
#[repr(transparent)]
#[derive(Clone)]
pub struct UndoManager<M>(Arc<Inner<M>>);

#[cfg(feature = "sync")]
Expand Down Expand Up @@ -555,6 +554,18 @@ where
!self.0.undo_stack.is_empty()
}

/// Returns a list of [StackItem]s stored within current undo manager responsible for performing
/// potential undo operations.
pub fn undo_stack(&self) -> &[StackItem<M>] {
&self.0.undo_stack.0
}

/// Returns a list of [StackItem]s stored within current undo manager responsible for performing
/// potential redo operations.
pub fn redo_stack(&self) -> &[StackItem<M>] {
&self.0.redo_stack.0
}

/// Undo last action tracked by current undo manager. Actions (a.k.a. [StackItem]s) are groups
/// of updates performed in a given time range - they also can be separated explicitly by
/// calling [UndoManager::reset].
Expand Down

0 comments on commit b3f9d92

Please sign in to comment.