Data Sets as Files: ask again with the stopped document's sets, and keep earlier skipped sets in No's status (#13767)

The next missing-image question read the active document's data sets, so a document made active
while the first question was open made the next Yes end the export as "changed". No after an
earlier Yes listed only the set it stopped at; it now lists every set left out.
This commit is contained in:
qvest-ssels committed 2026-11-29 10:09:14 +01:00
1 parent 17fbcc9f81
commit 44c80e3f48
2 files changed
+50 -2

No files matched your search

@@ -214,3 +214,41 @@ fn data_sets_changed_while_asking_end_the_export_instead_of_resuming_at_another_
assert!(app.ui.status_error && app.ui.status.contains("changed"), "{}", app.ui.status);
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn no_after_an_earlier_yes_lists_every_set_left_out() {
let dir = scratch("yes-no-status");
let out = dir.join("out");
let (mut app, ctx) = app(&dir, &[true, false, false, true]);
export_from_form(&mut app, &ctx, &out);
let (id, _) = question(&app).unwrap();
answer(&mut app, &ctx, id, true);
let (id, _) = question(&app).expect("set 3 asks too");
answer(&mut app, &ctx, id, false);
assert_eq!(files(&out), ["Data_Set_1.png"], "No writes nothing more");
let status = &app.ui.status;
assert!(status.contains("Data Set 2") && status.contains("Data Set 3") && !app.ui.status_error, "both sets left out are listed: {status}");
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn another_document_made_active_while_asking_does_not_stop_the_next_yes() {
let dir = scratch("other-doc");
let out = dir.join("out");
let (mut app, ctx) = app(&dir, &[true, false, false, true]);
export_from_form(&mut app, &ctx, &out);
let (id, _) = question(&app).unwrap();
// A second document, with no data sets, becomes the active one while the question is open.
app.run("file.new", json!({"width": 8, "height": 8})).unwrap();
app.sync_views();
let other = app.session.active().unwrap().doc.id;
answer(&mut app, &ctx, id, true);
assert_eq!(app.session.active().unwrap().doc.id, other, "the other document stays active");
let (id, message) = question(&app).expect("set 3 asks");
assert!(message.contains("Data Set 3"), "{message}");
answer(&mut app, &ctx, id, true);
assert!(question(&app).is_none());
assert_eq!(files(&out), ["Data_Set_1.png", "Data_Set_4.png"], "the export goes on with the document it ran on");
assert!(!app.ui.status_error, "{}", app.ui.status);
let _ = std::fs::remove_dir_all(dir);
}
+12 -2
View File
@@ -1122,7 +1122,9 @@ fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option<photocraft_doc::DocId>
return;
};
let message = crate::i18n::fmt(tl!("“{name}” was not exported: its replacement file was not found. Export the remaining data sets?"), &[("name", &name)]);
let sets = app.session.active().map(|st| st.doc.variables.data_sets.clone()).unwrap_or_default();
// The sets of the document the export ran on, as Yes compares them: a resumed run restores the document that was
// active, which may be another one by now.
let sets = app.session.documents().iter().find(|st| Some(st.doc.id) == doc).map(|st| st.doc.variables.data_sets.clone()).unwrap_or_default();
let tag = DataSetsMissingImage { doc, sets, params, name, resume: index.saturating_add(1), skipped };
let prompt = craft::ui::dialog::StandardPrompt::custom(message)
.title(tl!("Data Sets as Files"))
@@ -1141,7 +1143,15 @@ pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, an
let Some(mut pending) = answer.take_tag::<DataSetsMissingImage>() else { return false };
pending.skipped.push(pending.name.clone());
if answer.choice != craft::ui::dialog::PromptChoice::Proceed {
app.ui.status = crate::i18n::fmt(tl!("Data Sets as Files stopped at “{name}”"), &[("name", &pending.name)]);
// Sets skipped by an earlier Yes stay listed next to the one it stopped at.
app.ui.status = if pending.skipped.len() > 1 {
crate::i18n::fmt(
tl!("Data Sets as Files stopped at “{name}”. Data sets not exported (replacement file not found): {names}"),
&[("name", &pending.name), ("names", &pending.skipped.join(", "))],
)
} else {
crate::i18n::fmt(tl!("Data Sets as Files stopped at “{name}”"), &[("name", &pending.name)])
};
app.ui.status_error = false;
return true;
}