From 1628311e6b32c06bbfc62db2541890a4f2cfbb01 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:40:45 -0800 Subject: [PATCH] 3D: OK keeps the running preview and commits it OK in the 3D dialog replaced its live preview with a new one before running the values again. The new preview no longer owned the interaction the dialog's preview had started, so it ran nothing while that interaction was open, and the commit then refused with "Finish the active edit first." With Preview on, OK left the dialog open and saved nothing, and a refused draft reported that message instead of the engine's reason. OK now forgets only the values the preview last ran (LivePreview::rerun_next) and keeps its interaction, so the values run again inside it and the commit keeps that interaction as one undo step. This fixes four vectorcraft-ui-egui tests that fail on main under both cargo test and cargo nextest: - dialogs::revolve::tests::lighting_presets_cancel_restores_an_existing_custom_light_rig - dialogs::three_d::unchanged_tests::refused_three_d_preview_confirmation_retries_the_same_draft - dialogs::three_d::unchanged_tests::three_d_dialog_changed_options_commit_once_or_cancel - dialogs::track_cube::precision_tests::screen_plane_keys_preserve_the_untouched_rotation_axes_through_preview_and_ok --- crates/ui-egui/src/dialogs/preview.rs | 6 ++++++ crates/ui-egui/src/dialogs/three_d.rs | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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)) => {