From 27a20a3dfd639585a0853d5099d1c19b5d2afa73 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Fri, 20 Nov 2026 21:09:20 -0700 Subject: [PATCH] fix(tabs): History picks and Save As Command stay with their document (M8) --- src/tabs.rs | 4 ++++ src/tabs_tests.rs | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/tabs.rs b/src/tabs.rs index 5a4af045..9986017f 100644 --- a/src/tabs.rs +++ b/src/tabs.rs @@ -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 diff --git a/src/tabs_tests.rs b/src/tabs_tests.rs index ddd1613e..e8c0d3ac 100644 --- a/src/tabs_tests.rs +++ b/src/tabs_tests.rs @@ -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();