Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Integration: #1416 edit.cut removes the copied objects, not only their selected points

aiongg9555dbfc4804
diff --git a/crates/engine/src/cmd/anchors.rs b/crates/engine/src/cmd/anchors.rs
index 46b20ff38..4ccbeec7e 100644
--- a/crates/engine/src/cmd/anchors.rs
+++ b/crates/engine/src/cmd/anchors.rs
@@ -598,6 +598,10 @@ mod tests {
s.execute("selection.set", &json!({"anchors": [[a, 0, 0]]})).unwrap();
s.execute("edit.clear", &json!({})).unwrap();
assert_eq!(s.doc().unwrap().doc.item(ItemId(a)).unwrap().path.subpaths[0].anchors.len(), 3, "one point gone, the frame stays");
+ // Cut copies whole objects, so it removes whole objects.
+ s.execute("selection.set", &json!({"anchors": [[a, 0, 0]]})).unwrap();
+ s.execute("edit.cut", &json!({})).unwrap();
+ assert!(s.doc().unwrap().doc.item(ItemId(a)).is_none(), "the cut object is gone");
}
/// Shift-adding an object to a point selection drops the points, so Clear deletes the objects.
diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs
index 37ab535cb..7b9834f91 100644
--- a/crates/engine/src/cmd/edit.rs
+++ b/crates/engine/src/cmd/edit.rs
@@ -400,6 +400,11 @@ pub fn specs() -> Vec<CommandSpec> {
return Ok(json!({"text": text}));
}
copy_items(s)?;
+ // The whole objects are on the clipboard, so the whole objects go, not just selected points.
+ if p.get("ids").is_none() {
+ let ids: Vec<u64> = s.doc()?.selection.items.iter().map(|i| i.0).collect();
+ return s.execute("edit.clear", &json!({"ids": ids}));
+ }
s.execute("edit.clear", p)
}),
cmd!(