From 8ac4c03602e1f06f7c19a3ad39d4a660a449f3b6 Mon Sep 17 00:00:00 2001 From: Vvynot <925823079@qq.com> Date: Mon, 2 Nov 2026 13:44:01 +0000 Subject: [PATCH] Extrude: going back reaches the view it was clicked in from an open sketch (#10571) (#11035) Extrude started with the sketch still open ends the sketch on its way. With "If a sketch ends: Return to the previous view", that end starts a camera animation, and turn_for_extrude read the camera through settled_cam() - the target of that animation - so the view saved as "before Extrude" was where the sketch end was already turning, not where the command was clicked. The view is now taken before the sketch is finished. Co-authored-by: Claude Sonnet 5 --- crates/ui-egui/src/lib.rs | 9 ++++++++- crates/ui-egui/src/sketch_edit_tests.rs | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 21683ceb4..19ad180eb 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -527,6 +527,9 @@ pub struct SolveApp { /// The view from before Extrude turned it to isometric (#9176); the view goes back to it when /// the dialog closes, as the "and back when it closes" preference says. pub pre_extrude_cam: Option, + /// The view a command that ends an open sketch was clicked in (#10571), taken before the + /// sketch's own end turns the view: that turn must not become the view Extrude goes back to. + pre_command_cam: Option, /// The component active before Edit Sketch activated the one the sketch is in (#8127); /// leaving the sketch makes it active again. pub pre_sketch_component: Option, @@ -789,6 +792,7 @@ impl SolveApp { now: 0.0, pre_sketch_cam: None, pre_extrude_cam: None, + pre_command_cam: None, pre_sketch_component: None, services, file_picker: None, @@ -1899,6 +1903,9 @@ impl SolveApp { dialogs::cancel(self); } let finished_sketch = self.session.active_sketch.filter(|_| ends_sketch(id) && self.interactive(id)); + // The sketch's end may turn the view (Preferences › Sketch); Extrude goes back to the view + // it was clicked in, so take that one before the turn starts (#10571). + self.pre_command_cam = finished_sketch.is_some().then(|| self.settled_cam()); if finished_sketch.is_some() { self.finish_sketch(); // A feature committed before the marker is back would go in where the sketch was. @@ -2200,7 +2207,7 @@ impl SolveApp { if !self.preferences.extrude_view_isometric { return; } - let before = self.settled_cam(); + let before = self.pre_command_cam.take().unwrap_or_else(|| self.settled_cam()); let mut to = before; to.set_view(StandardView::Iso); self.pre_extrude_cam = self.preferences.extrude_view_return.then_some(before); diff --git a/crates/ui-egui/src/sketch_edit_tests.rs b/crates/ui-egui/src/sketch_edit_tests.rs index 792d793ab..ace851042 100644 --- a/crates/ui-egui/src/sketch_edit_tests.rs +++ b/crates/ui-egui/src/sketch_edit_tests.rs @@ -640,6 +640,29 @@ mod extrude_view_preference { assert_eq!(h.app.cam, iso_of(top), "{close}: isometric again"); } } + + /// #10571: Extrude clicked with the sketch still open ends the sketch on its way, and that + /// end turns the view back where it opened (Preferences › Sketch). The turn must not become + /// the view Extrude goes back to: it is the view the command was clicked in. + #[test] + fn extrude_from_an_open_sketch_goes_back_to_the_view_it_was_clicked_in() { + let mut h = Harness::new(); + h.app.preferences.extrude_view_isometric = true; + h.app.preferences.extrude_view_return = true; + h.app.preferences.sketch_exit_view = crate::prefs::SketchExitView::Previous; + h.app.run("sketch.create", json!({"plane": "XY"})).unwrap(); + h.app.run("sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [40, 30]})).unwrap(); + h.call("ui.view", json!({"view": "top"})); + h.settle(); + let top = h.app.cam; + open_extrude(&mut h); + assert_eq!(h.app.cam, iso_of(top), "isometric while Extrude is open"); + h.step(&json!({"widget": "Cancel"})).unwrap(); + h.settle(); + assert!(h.app.dialog.is_none()); + assert_eq!(h.app.session.active_sketch, None, "Extrude ended the sketch"); + assert_eq!(h.app.cam, top, "back to the sketch view it was clicked in"); + } } /// #8127: a sketch inside an inserted fastener, opened from its row in the browser, activates the