Merge pull request #2970 from nrq6993-a11y/stream/vc-issue-2178-pathfinder-ungroup

Fix #2178: Pathfinder Unite groups disconnected islands for Ungroup
This commit is contained in:
BFlat
2026-10-22 00:25:33 +07:00
committed by GitHub
+38
View File
@@ -205,6 +205,44 @@ fn a_group_selected_alone_is_combined_member_by_member() {
assert_eq!((bounds.x0, bounds.x1), (0.0, 10.0), "the back member less the front one");
}
/// #2178: Unite on separated shapes is one compound path; Release releases each subpath (Illustrator parity).
#[test]
fn pathfinder_unite_non_overlapping_shapes_become_compound_path_releasable() {
let mut s = session();
let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0);
let b = rect(&mut s, 30.0, 0.0, 20.0, 20.0);
let layer = s.doc().unwrap().doc.parent_of(a).unwrap();
s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap();
s.execute("object.pathfinder.unite", &json!({})).unwrap();
let result = s.doc().unwrap().selection.objects[0];
let united = node(&s, result);
assert!(matches!(united.kind, NodeKind::Compound { .. }));
assert_eq!(united.children().unwrap().len(), 2);
s.execute("object.compoundPath.release", &json!({})).unwrap();
let d = &s.doc().unwrap().doc;
assert!(d.node(result).is_none());
assert_eq!(s.doc().unwrap().selection.len(), 2);
for id in &s.doc().unwrap().selection.objects {
assert_eq!(d.parent_of(*id), Some(layer));
}
}
/// #2178: Unite keeps disjoint geometry in one compound path (not a group of separate path objects).
#[test]
fn pathfinder_unite_disjoint_islands_stay_one_compound_path() {
let mut s = session();
let outer = rect(&mut s, 0.0, 0.0, 40.0, 40.0);
let hole = rect(&mut s, 10.0, 10.0, 10.0, 10.0);
s.execute("select.set", &json!({"ids": [outer.0, hole.0]})).unwrap();
let ring = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap());
let separate = rect(&mut s, 60.0, 0.0, 20.0, 20.0);
s.execute("select.set", &json!({"ids": [ring.0, separate.0]})).unwrap();
s.execute("object.pathfinder.unite", &json!({})).unwrap();
let result = s.doc().unwrap().selection.objects[0];
assert!(matches!(node(&s, result).kind, NodeKind::Compound { .. }));
assert_eq!(path_of(&s, result).0.subpaths.len(), 3);
}
#[test]
fn unite_with_group() {
let mut s = session();