Pathfinder Unite: compound path, not group (#2178)

Illustrator documents Unite as a single compound path; use shape_node_styled and compoundPath.release in tests instead of wrapping islands in groups.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
nrq6993-a11y
2026-10-22 00:01:36 +07:00
committed by bflatastic
co-authored by Cursor
parent 0650c24a09
commit 7ceaf900d6
2 changed files with 16 additions and 37 deletions
+4 -20
View File
@@ -300,7 +300,6 @@ fn shape_node_styled(d: &mut Document, path: PathData, style: &Style) -> Node {
n
}
/// Whether `ids` are separate objects, as [`Document::remove_many`] and [`Document::insert_beside`]
/// take them: each one is in the tree and listed once, and none lies inside another listed one.
pub(crate) fn separate(d: &Document, ids: &[NodeId]) -> bool {
@@ -465,29 +464,14 @@ fn run_pf(s: &mut Session, op: PathfinderOp) -> Result<Value> {
let r =
results.into_iter().find(|r| !r.path.is_empty()).ok_or_else(|| EngineError::Other(format!("{label} produced an empty result")))?;
let style = styles.get(r.key as usize).ok_or_else(|| EngineError::Other(format!("{label}: lost track of a shape's style")))?;
let name = match op {
let mut n = shape_node_styled(d, r.path, style);
n.name = match op {
// A subtraction keeps its surviving source's identity, even when unnamed.
PathfinderOp::MinusFront => names.first().cloned().flatten(),
PathfinderOp::MinusBack => names.last().cloned().flatten(),
_ => names.into_iter().flatten().next(),
};
let path = r.path;
if op == PathfinderOp::Unite {
let pieces = super::draw2::components(&path);
if pieces.len() > 1 {
let children = pieces.into_iter().map(|p| Arc::new(shape_node_styled(d, p, style))).collect();
let mut g = Node::group(d.alloc_id(), children);
g.name = name;
g
} else {
let mut n = shape_node_styled(d, path, style);
n.name = name;
n
}
} else {
let mut n = shape_node_styled(d, path, style);
n.name = name;
n
}
n
} else {
let mut children = vec![];
for r in results {