PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Save: a plain Save records its Targa answer too
Higgs325843d27feac180f
diff --git a/crates/ui-egui/src/file_dialog/tests.rs b/crates/ui-egui/src/file_dialog/tests.rsindex 1237c518b..b3b44c731 100644--- a/crates/ui-egui/src/file_dialog/tests.rs+++ b/crates/ui-egui/src/file_dialog/tests.rs@@ -1201,6 +1201,15 @@ fn save_of_a_flat_file_asks_after_the_dialog_when_another_app_changed_it() {assert_eq!(app.session.journal.last(), Some(&("file.save".to_string(), json!({}))), "still recorded as a plain Save");}+/// A replayed plain Save keeps its Targa answer in the step it records, as well as its JPEG one.+#[test]+fn a_replayed_plain_save_records_its_targa_answer() {+ let (mut app, _, written) = jpeg_app(Some("/pics/photo.tga"), false);+ app.replay_save("file.save", &json!({"tgaBits": 24})).unwrap();+ assert_eq!(*written.borrow(), ["/pics/photo.tga"]);+ assert_eq!(app.session.journal.last(), Some(&("file.save".to_string(), json!({"tgaBits": 24}))));+}+/// A script's JPEG Options answer survives the changed-on-disk prompt: Replace writes with it,/// without asking JPEG Options.#[test]diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 5f69a23f9..ad5a147c8 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1601,7 +1601,11 @@ impl PhotocraftApp {return Err(SAVE_OPTIONS_OPEN.into());}let r = self.write_save(path, None, choices)?;- self.session.journal.push(("file.save".into(), jpeg_options_ui::plain_save_step(choices.jpeg)));+ let mut step = jpeg_options_ui::plain_save_step(choices.jpeg);+ if let Some(bits) = choices.tga_bits {+ step["tgaBits"] = bits.bits().into();+ }+ self.session.journal.push(("file.save".into(), step));Ok(r)}