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 <noreply@anthropic.com>
This commit is contained in:
VvynotandClaude Sonnet 5 authored and GitHub committed 2026-11-02 13:44:01 +00:00
1 parent 063f481ea0
commit 8ac4c03602
2 files changed
+31 -1

No files matched your search

+8 -1
View File
@@ -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<Camera>,
/// 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<Camera>,
/// 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<PreSketchComponent>,
@@ -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);
+23
View File
@@ -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