From 94c815d97194d97cf3a290b438b267c933893d4f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 08:36:20 -0800 Subject: [PATCH] Paint: invert and complement of design art alone still reject a bad target paint.invert and paint.complement given only the art of a graph design, with no item, returned success for a target other than "object" or "contents", because the topmost-fill path read the target only after the early return for design art. The target is now read before that return. --- crates/engine/src/cmd/graph/tests.rs | 2 ++ crates/engine/src/cmd/paint.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index 93cf1cf51b..65715e44d1 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -563,8 +563,10 @@ fn paint_edits_of_design_art_alone_leave_the_defaults() { json!({"ids": [art.0], "item": "top"}), json!({"ids": [art.0], "item": fill, "aligned": "yes"}), json!({"ids": [art.0], "item": fill, "target": "nowhere"}), + json!({"ids": [art.0], "target": "nowhere"}), ] { assert!(s.execute("paint.invert", &bad).is_err(), "{bad}"); + assert!(s.execute("paint.complement", &bad).is_err(), "{bad}"); } // So is an `item` the art has no row for, in each command that leaves the art out. let steps = s.doc().unwrap().history.undo.len(); diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index 0870c1cd1a..ef15f896cd 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -1098,6 +1098,8 @@ fn proxy_recolor(s: &mut Session, p: &Value, cmd: &str, label: &str, f: &dyn Fn( ItemTarget::Item { .. } => super::appearance::reference_of(s, p, item, cmd)?, ItemTarget::Top => None, }; + // Read before the check below too: `targets` reads no `target` for the topmost fill or stroke. + let contents = super::appearance::targets_contents(p)?; let ids = super::appearance::drop_design_art(&s.doc()?.doc, ids); // Only design art was given or selected: nothing changes, the defaults and remembered colors included. if ids.is_empty() { @@ -1128,7 +1130,6 @@ fn proxy_recolor(s: &mut Session, p: &Value, cmd: &str, label: &str, f: &dyn Fn( // objects change as their paint targets do (a compound path's member stands for the compound path). Design art // inside a given graph or series group is left out. ItemTarget::Top => { - let contents = super::appearance::targets_contents(p)?; let mut roots = vec![]; for id in &ids { let n = s.doc()?.doc.node(*id);