diff --git a/crates/ui-egui/src/dialogs/preview.rs b/crates/ui-egui/src/dialogs/preview.rs index 2e029fc1c6..f55dadb7c6 100644 --- a/crates/ui-egui/src/dialogs/preview.rs +++ b/crates/ui-egui/src/dialogs/preview.rs @@ -94,6 +94,12 @@ impl LivePreview { Some(answer) } + /// Forgets the values last previewed and keeps the interaction they ran in, so the next [`Self::run`] previews + /// them again inside that interaction and returns the command's answer, a refusal included. + pub(crate) fn rerun_next(&mut self) { + self.previewed = None; + } + /// OK: keeps the previewed `cmd` as one undo step, or, when its preview is not running, keeps typing in progress /// and runs `cmd` as a step of its own; the command's warning, or a plug-in run's notice, shows in the status bar /// either way. Another edit in progress is left as it is and OK is refused. On an error the dialog stays open. diff --git a/crates/ui-egui/src/dialogs/three_d.rs b/crates/ui-egui/src/dialogs/three_d.rs index 4706074962..293aae4f45 100644 --- a/crates/ui-egui/src/dialogs/three_d.rs +++ b/crates/ui-egui/src/dialogs/three_d.rs @@ -254,8 +254,9 @@ fn ok(app: &mut VectorcraftApp, answer: &ParamResult) -> Result<(), String> { return Err(why); } let (cmd, p, _) = s.request(&answer.fields); - // OK must validate afresh: the live preview also caches refused requests. - s.preview = LivePreview::default(); + // OK must validate afresh: the live preview also caches refused requests. The preview keeps its interaction, so + // the values run again inside it and the commit below keeps that interaction as the undo step. + s.preview.rerun_next(); match s.run_preview(app, cmd, &p) { Some(Ok(())) if finish_unchanged_preview(app) => return Ok(()), Some(Err(why)) => {