diff --git a/crates/engine/src/cmd/geolibre.rs b/crates/engine/src/cmd/geolibre.rs index 28034852c3..d52969fc4d 100644 --- a/crates/engine/src/cmd/geolibre.rs +++ b/crates/engine/src/cmd/geolibre.rs @@ -165,6 +165,8 @@ fn import_project(s: &mut Session, p: &Value) -> CmdResult { s.wait_in_place_reads(); order.reverse(); s.map_mut().layers.sort_by_key(|l| order.iter().position(|id| *id == l.id).unwrap_or(usize::MAX)); + // Its own direct `request_import_url` calls (a remote layer left for the app) set the flag, but + // this import edited the project: it keeps its undo step. s.request_only = false; s.map_mut().camera = project.camera; s.map_mut().bookmarks = project.bookmarks; diff --git a/crates/engine/src/cmd/plugins.rs b/crates/engine/src/cmd/plugins.rs index 4ade73bbf7..29cad0c6b7 100644 --- a/crates/engine/src/cmd/plugins.rs +++ b/crates/engine/src/cmd/plugins.rs @@ -943,8 +943,13 @@ impl Session { bridge.s.quiet_failure = true; return Err(String::new()); } - // Nor is a command that only left downloads for the front end: they add their - // layers, each its own undo step, when they land. + // Nor is a command that only left downloads for the front end: they add their layers, each + // its own undo step, when they land. Any other plugin command that may edit keeps its step + // even if it changed nothing, as a built-in command that mutates does unless it says it + // changed nothing, which a plugin's answer can't (`a_pending_answer_is_no_undo_step`); two + // tests pin it (`plugin_settings_are_kept_per_plugin_across_sessions_updates_and_toggles`, + // `shape_conversion_plugin_handled_rejection_is_atomic_and_has_no_inner_undo`). A script or + // task takes none when no line edited (see #2622). let steps = bridge.s.shared_steps; bridge.s.request_only = res.is_ok() && (state_command || steps.requested) && !steps.edited; res @@ -1095,6 +1100,7 @@ impl Host for Between<'_> { let res = s.guarded(leak(&plugin.manifest.name), mutates, |s| { let (res, changed, requested) = bridge(s); // Only left downloads for the app (they add their layers when they land): no step. + // The same rule as a plugin command's (see `run_plugin`). s.request_only = res.is_ok() && requested && !changed; // The answer goes to the program, which says what it makes of a refusal. s.quiet_failure = res.is_err(); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 29b4d17548..77a6aa7a57 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -1092,6 +1092,8 @@ pub struct Session { /// Set by [`Session::request_url`] for [`Session::guarded`]: the command running changed /// nothing, it only left a request (a plugin's own answer can't claim that). Also set by a move /// that left everything where it was (`layout.arrange`, `layer.move`): no step to undo. + /// Each command has its own: [`Session::guarded`] clears it on entry and puts the enclosing + /// command's back on exit. request_only: bool, /// What the commands run as steps of the transaction running now did ([`Session::shared_step`]): /// the one account scripts, tasks and plugins decide their undo step from. @@ -2356,7 +2358,8 @@ impl Session { self.restorable += u32::from(mutates); // Edit counts roll back with the project when a command fails part way. let counts = mutates.then(|| self.edit_counts.clone()); - self.request_only = false; + // Its flag is its own: the enclosing command's comes back after it, whatever it left. + let outer_request_only = std::mem::take(&mut self.request_only); // Its steps' account is its own: an enclosing command's comes back after it. let outer_steps = std::mem::take(&mut self.shared_steps); self.quiet_failure = false; @@ -2513,6 +2516,7 @@ impl Session { } _ => {} } + self.request_only = outer_request_only; if res.is_err() { self.restore_url_request_checkpoint(requests); (self.plugin_retries, self.url_waits) = retry_state; diff --git a/crates/engine/src/model.rs b/crates/engine/src/model.rs index 45dc309a62..d135ec5657 100644 --- a/crates/engine/src/model.rs +++ b/crates/engine/src/model.rs @@ -843,9 +843,7 @@ fn run_into(s: &mut Session, g: &ModelGraph, report: &mut RunReport) -> Result