fix(script): keep undo groups atomic beyond history limit (#810)

This commit is contained in:
Nigel Ihza Firdausy
2026-10-11 21:23:02 +07:00
parent 9a7d3e7699
commit 6d757e0061
2 changed files with 59 additions and 17 deletions
+22
View File
@@ -730,3 +730,25 @@ fn import_options_sequence_picks_one_still_or_the_run() {
assert_eq!(kind_of(&s, "shot_[0001-0003].png"), FootageKind::Sequence);
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn long_script_undo_group_counts_as_one_level() {
let mut s = session();
s.prefs.general.undo_levels = 3;
ok(&mut s, "var c = app.project.items.addComp('Long Undo', 100, 100, 1, 1, 24); c.layers.addNull();");
assert_eq!(s.history.undo.len(), 2);
// More edits than the history cap must still be one undoable group.
ok(
&mut s,
"var c = app.project.item(1); app.beginUndoGroup('Forty layers'); for (var i = 0; i < 40; i++) c.layers.addNull(); app.endUndoGroup();",
);
assert_eq!(s.project.comp(ItemId(1)).unwrap().layers.len(), 41);
assert_eq!(s.history.undo.len(), 3);
assert_eq!(s.history.undo[2].0, "Forty layers");
s.undo();
assert_eq!(s.project.comp(ItemId(1)).unwrap().layers.len(), 1);
// Entries preceding the group remain available instead of being trimmed by
// the forty intermediate operations.
s.undo();
assert_eq!(s.project.comp(ItemId(1)).unwrap().layers.len(), 0);
}