fix(engine): count each id Shape Builder is given once (#1974)

This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-03 23:01:44 -05:00
1 parent 519ffd4987
commit 972ccc6a17
2 files changed
+12 -1

No files matched your search

+3 -1
View File
@@ -109,7 +109,9 @@ pub fn eligible(doc: &Document, ids: &[NodeId]) -> Vec<NodeId> {
out.push(id);
}
}
let ids: Vec<NodeId> = ids.iter().copied().filter(|i| doc.contains(*i)).collect();
// Each id counts once: a repeated group must not be walked once per repeat.
let mut seen = std::collections::BTreeSet::new();
let ids: Vec<NodeId> = ids.iter().copied().filter(|i| doc.contains(*i) && seen.insert(*i)).collect();
let mut out = Vec::new();
for id in roots(doc, &ids) {
walk(doc, id, 0, &mut out);
+9
View File
@@ -217,6 +217,15 @@ fn remove_mode_and_escape() {
assert!(s.execute("shapeBuilder.mode", &json!({"mode": "sideways"})).is_err());
}
#[test]
fn a_group_named_many_times_is_walked_once() {
let mut s = Session::new();
let (a, b) = squares(&mut s);
let g = id(&ex(&mut s, "object.group", json!({"ids": [a, b]})));
let r = ex(&mut s, "shapeBuilder.regions", json!({"ids": vec![g; 500]}));
assert_eq!(r["sources"], json!([a, b]));
}
#[test]
fn groups_rotated_and_ineligible_layers() {
let mut s = Session::new();