Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge PR #7219: Actions: record File › Export › Export As and replay it with its settings (#7207)

aiongg5eada4996a2b
diff --cc crates/engine/src/actions_cmds.rs
index 0d1cb29cd,69f8d3f4e..0694dd64b
--- a/crates/engine/src/actions_cmds.rs
+++ b/crates/engine/src/actions_cmds.rs
@@@ -125,24 -121,13 +125,24 @@@ pub fn replayable(id: &str) -> bool
&& (shell_view_command(id) || shell_save_command(id) || crate::commands::find(id).is_some_and(|c| c.journal)))
}
- /// File › Save, Save As and Save a Copy, recorded by the desktop shell once the save has a path
- /// (#2032, #4373). The shell replays them; batch and droplets write to their destination folder
- /// instead.
+ /// File › Save, Save As and Save a Copy, and File › Export › Export As, recorded by the desktop
+ /// shell once the file has a path (#2032, #4373, #7207). The shell replays them; batch and
+ /// droplets write to their destination folder instead.
pub fn shell_save_command(id: &str) -> bool {
- matches!(id, "file.save" | "file.saveAs" | "file.saveACopy")
+ matches!(id, "file.save" | "file.saveAs" | "file.saveACopy" | "file.export.exportAs")
}
+/// The failure for a played Save step whose document `target` (the one active when the step
+/// started) is no longer open: a Save Document script event closed it. Playback stops there, so
+/// the next step without a document, such as the Close half of an imported Close with Save: Yes,
+/// doesn't act on whichever document is active now (#7367).
+pub fn save_target_closed(s: &Session, id: &str, target: Option<photocraft_doc::DocId>) -> Option<String> {
+ let target = target.filter(|_| shell_save_command(id))?;
+ (!s.documents().iter().any(|d| d.doc.id == target)).then(|| {
+ "the document was closed during the save (by a Save Document script event); playback stopped so later steps don't act on another document".into()
+ })
+}
+
/// View-only menu commands recorded by the desktop shell. Headless playback reports
/// them as unsupported instead of silently dropping them; Batch and droplets skip them.
pub fn shell_view_command(id: &str) -> bool {