diff --git a/crates/engine/src/macros/run.rs b/crates/engine/src/macros/run.rs index 6a6d3f5c8..373d61d8b 100644 --- a/crates/engine/src/macros/run.rs +++ b/crates/engine/src/macros/run.rs @@ -998,6 +998,9 @@ struct Saved { /// The workbook as last saved: `sheet.activate` and the view commands move it to the /// current workbook on a clean document, and the rollback puts the workbook back but not this. saved: Option>, + /// The document's revision: the rollback counts as a change, and front ends key their caches + /// on it, so a check that changed nothing leaves it as it was. + revision: Option, sheet_selections: Vec, unlocked_ranges: Vec<(String, String)>, trust: Trust, @@ -1027,6 +1030,7 @@ impl Saved { active: s.active, docs: s.docs.iter().map(|d| d.uid).collect(), saved: d.map(|d| d.saved.clone()), + revision: d.map(|d| d.revision), sheet_selections: d.map(|d| d.sheet_selections.clone()).unwrap_or_default(), unlocked_ranges: d.map(|d| d.unlocked_ranges.clone()).unwrap_or_default(), trust: d.map_or(Trust::Local, |d| d.trust), @@ -1054,6 +1058,9 @@ impl Saved { if let Some(saved) = self.saved { d.saved = saved; } + if let Some(revision) = self.revision { + d.revision = revision; + } d.sheet_selections = self.sheet_selections; d.unlocked_ranges = self.unlocked_ranges; d.trust = self.trust; diff --git a/crates/engine/src/tests/macros.rs b/crates/engine/src/tests/macros.rs index 50fbcfc14..d94494ba5 100644 --- a/crates/engine/src/tests/macros.rs +++ b/crates/engine/src/tests/macros.rs @@ -304,12 +304,14 @@ fn shifting_makes_room_and_is_checked_again() { let err = s.execute("macro.run", json!({"name": "Named"})).unwrap_err().to_string(); assert!(err.contains("shifting the data didn't make room (E3 on Sheet1)"), "{err}"); assert!(Arc::ptr_eq(&s.doc().unwrap().wb, &start)); - // The check shifts and checks again as the run does, and puts everything back. + // The check shifts and checks again as the run does, and puts everything back, the document's + // revision included. let journal = s.journal.len(); + let revision = s.doc().unwrap().revision; let c = s.execute("macro.check", json!({"name": "Named"})).unwrap(); assert_eq!((&c["ok"], &c["errors"]), (&json!(false), &json!(["Shifting the data doesn't make room (E3 on Sheet1)."])), "{c}"); assert!(Arc::ptr_eq(&s.doc().unwrap().wb, &start)); - assert_eq!(s.journal.len(), journal); + assert_eq!((s.journal.len(), s.doc().unwrap().revision), (journal, revision)); // Where the shift does make room, the check says the run would go ahead. let mut s = super::s(); data(&mut s);