From b448afdc57249876db28e61e08ff0584e14b6996 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 20 Apr 2021 19:52:47 +1000 Subject: [PATCH] change detection needs to ignore collection mtime bump --- rslib/src/undo/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 {