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
This commit is contained in:
dotCooCoo committed 2026-11-28 09:40:45 -08:00
1 parent 98c3a3fe08
commit 1628311e6b
2 files changed
+9 -2

No files matched your search

+6
View File
@@ -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.
+3 -2
View File
@@ -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)) => {