From 13fb00fd087895c7ac06971bef5df9287d724a03 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 11 Oct 2026 19:11:53 +0000 Subject: [PATCH] Integration: transform.move on content reports the ids it moved (#521) #521 makes transform.move return {moved, ids}; next's move_content (the content-selection path, content?) returned only {moved}. It returns the ids of the items whose content or frame moved, and copies_report_their_ids checks it. --- crates/engine/src/cmd/object.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rs index c8a00173d..2935e3e6f 100644 --- a/crates/engine/src/cmd/object.rs +++ b/crates/engine/src/cmd/object.rs @@ -1023,7 +1023,7 @@ fn linear_inverse(m: Affine, v: Vec2) -> Vec2 { /// frame resize refits. fn move_content(s: &mut Session, ids: &[ItemId], d: Vec2) -> Result { s.edit(|doc, _| { - let mut moved = 0; + let mut moved = Vec::new(); for id in ids { let loc = doc.find(*id).ok_or(designcraft_doc::DocError::NoItem(*id))?; let parent = doc.parent_xf(&loc); @@ -1043,9 +1043,9 @@ fn move_content(s: &mut Session, ids: &[ItemId], d: Vec2) -> Result { } _ => it.xf = Affine::translate(linear_inverse(parent, d)) * it.xf, } - moved += 1; + moved.push(id.0); } - Ok(json!({"moved": moved})) + Ok(json!({"moved": moved.len(), "ids": moved})) }) } @@ -3415,6 +3415,7 @@ mod copy_ids_tests { let selected = |s: &crate::Session| s.doc().unwrap().selection.items.iter().map(|i| i.0).collect::>(); // Moving reports what moved; copying reports the copies, which are selected. assert_eq!(ids(&s.execute("transform.move", &json!({"dx": 5, "dy": 0, "ids": [a]})).unwrap()), [a]); + assert_eq!(ids(&s.execute("transform.move", &json!({"dx": 5, "dy": 0, "ids": [a], "content": true})).unwrap()), [a]); let r = s.execute("transform.move", &json!({"dx": 100, "dy": 0, "copy": true, "ids": [a]})).unwrap(); let copy = ids(&r); assert!(copy.len() == 1 && copy[0] != a && s.doc().unwrap().doc.item(designcraft_doc::ItemId(copy[0])).is_some(), "{r}");