Editing a sketch past the history marker rolls the marker to it (#2716) (#3339)

* claim: #2716

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Editing a sketch past the history marker rolls the marker to it (#2716)

Edit Sketch rolled the timeline back to just after the sketch only when
the marker was later. With the marker before the sketch it stayed there:
the sketch wasn't built, so it opened with no palette and couldn't be
edited. The marker now moves to just after the sketch either way, and
Finish Sketch puts it back as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Phanoob <phanoob@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
phanoob
2026-10-20 15:28:52 +00:00
committed by GitHub
parent 7bda28e786
commit 83790139b1
2 changed files with 23 additions and 4 deletions
+4 -4
View File
@@ -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 {
+19
View File
@@ -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();