From 90a46da4968dfa132f4f61166552343f09cbda7f Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Sun, 25 Oct 2026 04:13:05 -0400 Subject: [PATCH 1/2] Engine: macro.run's description lists only what it returns here `shifted` comes with the footprint in the pull request above; here a shift rule stops the run as `fail` does, which the description now says. --- crates/engine/src/cmd/macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/macros.rs b/crates/engine/src/cmd/macros.rs index d81902b1b..e53482e94 100644 --- a/crates/engine/src/cmd/macros.rs +++ b/crates/engine/src/cmd/macros.rs @@ -11,7 +11,7 @@ pub fn specs() -> Vec { "Run Macro", [], None, - "{name, inputs?: {Input: \"B2:D9\"} | \"B2:D9\", onConflict?: ask|fail|overwrite|shiftDown|shiftRight, overwrite?: bool, approve?: bool, timeLimit?: seconds} runs as one undo step; any error rolls it all back → {macro, ran, inputs, stopped?, shifted?}", + "{name, inputs?: {Input: \"B2:D9\"} | \"B2:D9\", onConflict?: ask|fail|overwrite|shiftDown|shiftRight (a shift stops the run as fail does), overwrite?: bool, approve?: bool, timeLimit?: seconds} runs as one undo step; any error rolls it all back → {macro, ran, inputs, stopped?}", has_doc, run )] From f6f4585c931c5edca099bb4d66027a49310bc751 Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Sun, 25 Oct 2026 04:14:12 -0400 Subject: [PATCH 2/2] Engine: a dry run puts the document's revision back The dry run's rollback counts as a change of the document and moves its revision on, which front ends key their caches on, so a `macro.check` that changed nothing (and a shift it tried and took back) looked like a change. `Saved` keeps the revision and puts it back with the rest. - Test: the revision in `shifting_makes_room_and_is_checked_again`. --- crates/engine/src/macros/run.rs | 7 +++++++ crates/engine/src/tests/macros.rs | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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);