From 5fae9a15ee1aa92a68ebb7ab8b4d8f25f4e24fc0 Mon Sep 17 00:00:00 2001 From: devstivi <340315248+devstivi@users.noreply.github.com> Date: Sat, 24 Oct 2026 08:46:05 +0700 Subject: [PATCH] Ask afresh about documents found after Apply to All Close All and quitting look for documents dirtied while the prompt was up once the first ones are answered. Apply to All only covers the documents it was given, so the stored answer is cleared when that second list is asked about. --- crates/ui-egui/src/discard_ui.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/ui-egui/src/discard_ui.rs b/crates/ui-egui/src/discard_ui.rs index bf9b0714a7..9f1e128012 100644 --- a/crates/ui-egui/src/discard_ui.rs +++ b/crates/ui-egui/src/discard_ui.rs @@ -186,6 +186,8 @@ fn advance(app: &mut PhotocraftApp, ctx: &egui::Context) { show_tab(app, rest.first().copied()); if let Some(p) = app.discard.as_mut() { p.docs = rest; + // Apply to All covered the documents asked about; these are asked about afresh. + (p.apply_all, p.auto, p.auto_answered) = (false, None, None); } return; } @@ -835,6 +837,25 @@ mod tests { assert_eq!(docs_left(&h), Some(2), "both documents are still waiting for an answer"); } + /// Apply to All answers for the documents the prompt opened with, not for ones dirtied since. + #[test] + fn a_document_dirtied_after_apply_to_all_is_asked_about() { + let mut app = app_with_docs(3); + make_dirty(&mut app, 0); + make_dirty(&mut app, 1); + let mut h = prompt_for(app, "file.closeAll", egui::os::OperatingSystem::Windows); + let late = doc_id(h.state(), 2); + make_dirty(h.state_mut(), 2); + if let Some(p) = h.state_mut().discard.as_mut() { + (p.apply_all, p.auto) = (true, Some(Answer::Discard)); + } + h.run_steps(8); + let prompt = h.state().discard.as_ref().unwrap(); + assert_eq!(prompt.docs, vec![late], "the two unsaved documents were discarded, the late one is asked about"); + assert!(prompt.auto.is_none() && !prompt.apply_all); + assert_eq!(h.state().session.documents().len(), 1); + } + #[test] fn control_clients_can_answer_for_all() { let mut app = app_with_docs(3);