Move: a copying Move can be edited from the History (#7741) (#7761)

* claim: #7741

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

* Move: a copying Move can be edited from the History (#7741)

Editing a feature runs its command on a scratch session with the marker
right after it. For the last feature that marker sits at the end of the
timeline, and place_feature pushed the new feature after it, rolled back,
so a copying Move found no copies and refused the edit. A marker right
after the last feature now moves on past a feature added there.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
semmelrinde
2026-10-27 18:47:01 +00:00
committed by GitHub
parent 143145751c
commit d14dbe5e39
3 changed files with 36 additions and 1 deletions
+3 -1
View File
@@ -3505,7 +3505,9 @@ impl Document {
let id = f.id;
let insertion_group = self.marker.and_then(|marker| self.timeline_group_at_insertion(marker));
match self.marker {
Some(m) if m < self.features.len() => {
// A marker right after the last feature moves on past a feature added there, or the
// new feature would be added rolled back (#7741).
Some(m) if m <= self.features.len() => {
self.features.insert(m, f);
self.marker = Some(m + 1);
}
+15
View File
@@ -562,6 +562,21 @@ fn feature_inserted_at_a_marker_inside_a_timeline_folder_joins_it() {
assert!(Document::from_json(&doc.to_json()).is_ok(), "the inserted feature must leave a reopenable design");
}
/// A marker after the last feature leaves every feature active, as no marker does, so a feature
/// added then is active too, not added rolled back (#7741: editing the last feature from the
/// History runs its command with the marker there).
#[test]
fn feature_added_with_the_marker_at_the_end_is_active() {
let mut doc = Document::new("marker at the end");
let first = doc.add_feature(FeatureKind::Sketch { plane: PlaneRef::Origin { name: "XY".into() }, sketch: Sketch::new() }, Some("First")).unwrap();
doc.marker = Some(1);
let added = doc.add_feature(FeatureKind::Sketch { plane: PlaneRef::Origin { name: "XY".into() }, sketch: Sketch::new() }, Some("Added")).unwrap();
assert_eq!(doc.features.iter().map(|feature| feature.id).collect::<Vec<_>>(), vec![first, added]);
assert_eq!(doc.marker, Some(2), "the marker stays after the last feature");
}
/// A construction plane that is its own side resolves through the model and back into the
/// document. The depth count has to survive that hop, or the recursion overflows the stack and
/// aborts the process, which no panic guard can intercept.
@@ -89,6 +89,24 @@ fn a_copied_body_keeps_the_appearance_of_the_body_it_came_from() {
assert_eq!(s.doc.appearances.bodies.get(&copy), Some(&source), "the copy must keep the appearance of the body it came from");
}
/// Editing a copying Move from the History redefines it on a scratch session, where the old Move
/// is still in the timeline as a suppressed placeholder (#7741).
#[test]
fn a_copying_move_can_be_edited_from_the_history() {
let mut s = Session::default();
cube20(&mut s, "Cube");
run(&mut s, "appearance.assign", json!({"bodies": ["Cube"], "appearance": "ABS - Blue"}));
let reply = run(&mut s, "solid.move", json!({"bodies": ["Cube"], "translate": [30, 0, 0], "copy": true}));
let feature = reply["feature"].clone();
let copy = created(&reply);
let edit = json!({"feature": feature, "command": "solid.move", "params": {"bodies": ["Cube"], "translate": [40, 0, 0], "copy": true}});
s.execute("timeline.redefine", &edit).expect("editing a copying move must keep copying");
assert_eq!(s.model.state().bodies.len(), 2, "the edited move still makes one copy");
assert_eq!(copy_of(&s, "Cube", Vec3::new(40.0, 0.0, 0.0)), copy, "the copy keeps its name and moves to the new place");
let source = s.doc.appearances.bodies.get("Cube").expect("the source body keeps its look").clone();
assert_eq!(s.doc.appearances.bodies.get(&copy), Some(&source), "the edited copy keeps the look of the body it came from");
}
#[test]
fn a_copied_body_keeps_the_material_of_the_body_it_came_from() {
let mut s = Session::default();