From 26d82b429cd5dcc225dc7d224af5ffa482a65a6c Mon Sep 17 00:00:00 2001 From: Rafael Mendes Date: Tue, 10 Nov 2026 18:32:29 -0300 Subject: [PATCH] effect.add.anchor without params goes on the content Null params left the target unset, so the anchor landed in the mask. --- crates/engine/src/mask_cmds.rs | 11 ++++------- crates/engine/tests/it/content_effects.rs | 4 +++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/mask_cmds.rs b/crates/engine/src/mask_cmds.rs index e793fbac..363a9b93 100644 --- a/crates/engine/src/mask_cmds.rs +++ b/crates/engine/src/mask_cmds.rs @@ -378,13 +378,10 @@ fn size_weights(command: &str, value: &Value) -> Result<[f32; CurvatureDetail::S /// An anchor point on the layer content (the default, as before anchors went on masks) or, with /// `target: "mask"`, in its mask. fn add_anchor(s: &mut Session, p: &Value) -> Result { - let mut params = p.clone(); - if p.get("target").is_none() - && let Some(o) = params.as_object_mut() - { - o.insert("target".into(), json!("content")); - } - push_effect(s, ¶ms, EffectKind::Anchor, BlendMode::Normal) + // Params may be null or an object without a target: both default to the content. + let mut params = p.as_object().cloned().unwrap_or_default(); + params.entry("target").or_insert_with(|| json!("content")); + push_effect(s, &Value::Object(params), EffectKind::Anchor, BlendMode::Normal) } /// A generator's micro detail from `microAnchor` / `microAmount` for a generator on layer diff --git a/crates/engine/tests/it/content_effects.rs b/crates/engine/tests/it/content_effects.rs index d10524fb..093597bf 100644 --- a/crates/engine/tests/it/content_effects.rs +++ b/crates/engine/tests/it/content_effects.rs @@ -106,9 +106,11 @@ fn anchor_points_in_masks_record_the_mask_for_layers_above() { let layer = s.doc.project.layer(LayerId(low)).unwrap(); assert!(layer.mask.as_ref().unwrap().effects.iter().any(|e| e.id.0 == anchor), "in the mask"); assert!(layer.content_effects.is_empty(), "not on the content"); - // Without a target it still goes on the content, as before. + // Without a target (or with no params at all) it still goes on the content, as before. let content = id(execute(&mut s, "effect.add.anchor", &json!({"layer": low})).unwrap(), "effect"); assert!(s.doc.project.layer(LayerId(low)).unwrap().content_effects.iter().any(|e| e.id.0 == content)); + let bare = id(execute(&mut s, "effect.add.anchor", &Value::Null).unwrap(), "effect"); + assert!(s.doc.project.layer(LayerId(low)).unwrap().content_effects.iter().any(|e| e.id.0 == bare)); // Folders take anchors in their masks only. let folder = id(execute(&mut s, "layer.add.group", &Value::Null).unwrap(), "layer");