PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Save: a plain Save keeps a script's JPEG or Targa answer when it is recorded
Higgs325848f5ba769e3a0
diff --git a/crates/ui-egui/src/file_dialog/tests.rs b/crates/ui-egui/src/file_dialog/tests.rsindex 23a06c2c5..1237c518b 100644--- a/crates/ui-egui/src/file_dialog/tests.rs+++ b/crates/ui-egui/src/file_dialog/tests.rs@@ -1229,4 +1229,6 @@ fn a_scripted_quality_survives_the_changed_on_disk_prompt() {assert!(app.jpeg_options.is_none(), "the script answered JPEG Options");assert_eq!(*written.borrow(), [path]);assert_eq!(qualities.borrow().last().copied().flatten(), Some(photocraft_engine::file_cmds::jpeg_quality(5.0)));+ // Recorded as a plain Save keeping the answer, so a replay writes the file it's played on.+ assert_eq!(app.session.journal.last(), Some(&("file.save".to_string(), json!({"quality": 5, "jpegFormat": "baseline"}))));}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex e6b7d1530..5f69a23f9 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1627,12 +1627,16 @@ impl PhotocraftApp {p.record = "file.save";return;}+ // Only the path goes: a script's JPEG or Targa answer stays, so a replay writes the file+ // it is played on the same way. Any other answer (TIFF layers) keeps the Save As.if let Some(last) = self.session.journal.last_mut()&& last.0 == "file.saveAs"&& last.1.get("path").and_then(Value::as_str) == Some(path)- && last.1.as_object().is_some_and(|o| o.len() == 1)+ && let Some(step) = last.1.as_object()+ && step.keys().all(|k| matches!(k.as_str(), "path" | "quality" | "jpegFormat" | "tgaBits")){- *last = ("file.save".into(), Value::Object(Default::default()));+ let step: serde_json::Map<String, Value> = step.iter().filter(|(k, _)| k.as_str() != "path").map(|(k, v)| (k.clone(), v.clone())).collect();+ *last = ("file.save".into(), Value::Object(step));}}