SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Editing a sketch past the history marker rolls the marker to it (#2716) (#3339)
phanoob83790139b1d6
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 8e68c929ba..514331e985 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -991,9 +991,9 @@ impl SolveApp {}}- /// Edit a sketch: roll the timeline back to just after it (so later- /// features don't hide it), turn the camera to face it, and remember both so Finish Sketch- /// puts them back. Editing the sketch that is already open does nothing; editing another one+ /// Edit a sketch: roll the timeline to just after it (back, so later features don't hide+ /// it, or forward from before it, where it isn't built yet: #2716), turn the camera to face+ /// it, and remember both so Finish Sketch puts them back. Editing the sketch that is already open does nothing; editing another one/// finishes the current sketch first, so edit sessions never nest.pub fn edit_sketch(&mut self, id: u64) {if let solidcraft_engine::doc::FaceAttachmentStatus::Lost { message, .. } =@@ -1013,7 +1013,7 @@ impl SolveApp {self.dialog = None;let Some(idx) = self.session.doc.feature_index(id) else { return };let marker = self.session.doc.marker;- let rolled = marker.is_none_or(|m| m > idx + 1) && self.run("timeline.roll_to", json!({ "position": idx + 1 })).is_ok();+ let rolled = marker != Some(idx + 1) && self.run("timeline.roll_to", json!({ "position": idx + 1 })).is_ok();let before = self.cam;if self.run("sketch.edit", json!({ "sketch": id })).is_err() {if rolled {diff --git a/crates/ui-egui/src/sketch_edit_tests.rs b/crates/ui-egui/src/sketch_edit_tests.rsindex 2430b5c7cc..bbb9b6d1ba 100644--- a/crates/ui-egui/src/sketch_edit_tests.rs+++ b/crates/ui-egui/src/sketch_edit_tests.rs@@ -28,6 +28,25 @@ fn edit_sketch_rolls_back_and_finish_restores() {assert_eq!(app.session.doc.marker, marker, "marker restored");}+/// #2716: with the history marker before a sketch, editing it rolls the marker forward to it+/// (it is built, its palette shows), and Finish puts the marker back.+#[test]+fn edit_sketch_rolls_forward_from_before_it_and_finish_restores() {+ let mut app = sample_app();+ let id = first_sketch(&app);+ let idx = app.session.doc.feature_index(id).unwrap();+ app.run("timeline.roll_to", serde_json::json!({ "position": idx })).unwrap();+ let marker = app.session.doc.marker;+ assert!(app.session.model.state().sketch(id).is_none(), "the sketch is past the marker");+ app.edit_sketch(id);+ assert_eq!(app.session.active_sketch, Some(id));+ assert_eq!(app.session.doc.marker, Some(idx + 1), "rolled forward to just after the sketch");+ assert!(app.session.model.state().sketch(id).is_some(), "the sketch is built");+ app.finish_sketch();+ assert_eq!(app.session.active_sketch, None);+ assert_eq!(app.session.doc.marker, marker, "marker restored");+}+#[test]fn editing_twice_does_not_nest() {let mut app = sample_app();