mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-30 05:37:00 -06:00
@@ -1043,6 +1043,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<Arc<Workbook>>,
|
||||
/// 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<u64>,
|
||||
sheet_selections: Vec<Selection>,
|
||||
unlocked_ranges: Vec<(String, String)>,
|
||||
trust: Trust,
|
||||
@@ -1072,6 +1075,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),
|
||||
@@ -1099,6 +1103,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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user