diff --git a/rslib/src/undo/mod.rs b/rslib/src/undo/mod.rs index a5c8bf19e..749151407 100644 --- a/rslib/src/undo/mod.rs +++ b/rslib/src/undo/mod.rs @@ -9,6 +9,7 @@ pub(crate) use changes::UndoableChange; pub use crate::ops::Op; use crate::{ + collection::undo::UndoableCollectionChange, ops::{OpChanges, StateChanges}, prelude::*, }; @@ -22,6 +23,18 @@ pub(crate) struct UndoableOp { pub changes: Vec, } +impl UndoableOp { + /// True if changes empty, or only the collection mtime has changed. + fn has_changes(&self) -> bool { + !matches!( + &self.changes[..], + &[] | &[UndoableChange::Collection( + UndoableCollectionChange::Modified(_) + )] + ) + } +} + #[derive(Debug, PartialEq)] enum UndoMode { NormalOp, @@ -82,7 +95,7 @@ impl UndoManager { fn end_step(&mut self) { if let Some(step) = self.current_step.take() { - if !step.changes.is_empty() { + if step.has_changes() { if self.mode == UndoMode::Undoing { self.redo_steps.push(step); } else {