fix(tabs): History picks and Save As Command stay with their document (M8)

This commit is contained in:
Tanish Manku committed 2026-11-20 21:09:20 -07:00
1 parent 4d42fa535f
commit 27a20a3dfd
2 files changed
+29

No files matched your search

+4
View File
@@ -306,6 +306,10 @@ fn settle(app: &mut App) {
app.ease = None;
app.layer_props = None;
app.aids_dialogs = Default::default();
// The History panel's picks and Save As Command number this document's undo steps: in
// another document the same numbers are other steps.
crate::macros_ui::clear_picks(app);
app.macros.save = None;
}
/// The document in `app` is another one from here on: nothing drawn for the last one is kept
+25
View File
@@ -121,6 +121,31 @@ fn switching_keeps_each_documents_undo_selection_playhead_and_view() {
assert_eq!((app.s.doc.stage.width, app.s.history_len(), app.view.fit), (640, 0, true));
}
#[test]
fn history_picks_and_save_as_command_stay_with_their_document() {
let (_ctx, mut app) = app();
app.macros.test_folder = Some(std::env::temp_dir().join(format!("anicraft-tabs-picks-{}", std::process::id())));
three(&mut app);
// The second document has as long a history as the third, so the same numbers name steps
// in both.
assert!(activate(&mut app, 1));
for x in [10, 80] {
app.run("draw.rect", json!({"x": x, "y": 10, "w": 50, "h": 50}));
}
assert!(activate(&mut app, 2));
for x in [10, 80] {
app.run("draw.ellipse", json!({"x": x, "y": 10, "w": 50, "h": 50}));
}
crate::macros_ui::pick(&mut app, 0, false, false);
crate::macros_ui::pick(&mut app, 1, true, false);
crate::macros_ui::open_save(&mut app);
assert!(app.macros.save.is_some() && crate::macros_ui::picked(&mut app).len() == 2);
// Shown another document, nothing is picked there and nothing waits to be saved from it.
assert!(activate(&mut app, 1));
assert!(app.macros.save.is_none(), "Save As Command listed the other document's steps");
assert!(crate::macros_ui::picked(&mut app).is_empty(), "the other document's picks");
}
#[test]
fn a_copy_in_one_document_pastes_into_another_with_its_symbols() {
let (_, mut app) = app();