From 5be03543dd87d7745019c6e42d76c06790d4f371 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 3 Jan 2025 16:57:00 +0800 Subject: [PATCH] history: Export `undos`, `redos` methods, and add `clear` method. (#527) --- crates/ui/src/history.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/ui/src/history.rs b/crates/ui/src/history.rs index 6a854b72..05eb9d23 100644 --- a/crates/ui/src/history.rs +++ b/crates/ui/src/history.rs @@ -80,6 +80,22 @@ where self.undos.push(item); } + /// Get the undo stack. + pub fn undos(&self) -> &Vec { + &self.undos + } + + /// Get the redo stack. + pub fn redos(&self) -> &Vec { + &self.redos + } + + /// Clear the undo and redo stacks. + pub fn clear(&mut self) { + self.undos.clear(); + self.redos.clear(); + } + pub fn undo(&mut self) -> Option> { if let Some(first_change) = self.undos.pop() { let mut changes = vec![first_change.clone()];