mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-17 07:35:07 +00:00
Anchored text frames: story revisions wrap in the repair, as everywhere else
This commit is contained in:
1 parent
1e1431f956
commit
d3221ed605
1 file changed
+18
-2
@@ -421,7 +421,7 @@ impl Document {
|
||||
changed += 1;
|
||||
}
|
||||
});
|
||||
st.rev += 1;
|
||||
st.rev = st.rev.wrapping_add(1);
|
||||
self.next_id = next;
|
||||
}
|
||||
// Frames that are gone (deleted with their text or their host's frame) leave their
|
||||
@@ -498,7 +498,7 @@ impl Document {
|
||||
t.story = story;
|
||||
}
|
||||
});
|
||||
st.rev += 1;
|
||||
st.rev = st.rev.wrapping_add(1);
|
||||
}
|
||||
changed += 1;
|
||||
}
|
||||
@@ -660,6 +660,22 @@ mod tests {
|
||||
assert_eq!(shown.iter().filter(|(_, t)| t.starts_with("Inner ")).count(), 2, "{shown:?}");
|
||||
}
|
||||
|
||||
/// The repair bumps the revisions of the stories it changes; a revision at its maximum wraps
|
||||
/// around instead of overflowing.
|
||||
#[test]
|
||||
fn the_repair_wraps_story_revisions_at_their_maximum() {
|
||||
let (mut d, host) = doc();
|
||||
anchor(&mut d, host, "Inner ");
|
||||
let copy = d.story(host).unwrap().extract(0..d.story(host).unwrap().len());
|
||||
let h = d.story_mut(host).unwrap();
|
||||
let n = h.len();
|
||||
h.insert_story(n, ©);
|
||||
Arc::make_mut(d.stories.get_mut(&host).unwrap()).rev = u64::MAX;
|
||||
assert!(d.fix_anchored_text_frames() > 0);
|
||||
d.check().unwrap();
|
||||
assert_ne!(d.story(host).unwrap().rev, u64::MAX);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deleted_anchored_text_frames_take_their_stories_along() {
|
||||
// With the text they are anchored in.
|
||||
|
||||
Reference in new issue
Block a user