PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Expand New Effects follows the layer a Layer Style command changes
abc2cb792413b5281c
diff --git a/crates/engine/src/jobs.rs b/crates/engine/src/jobs.rsindex 00b83682b..5566d39c3 100644--- a/crates/engine/src/jobs.rs+++ b/crates/engine/src/jobs.rs@@ -725,9 +725,12 @@ impl Session {let run_params = self.admit(id, spec, ¶ms)?;// This UI-only disclosure preference applies to both `execute` and `start`:// desktop UI normally calls `start`, even for synchronous Layer Style commands.+ // The layer the command will change, named as the command accepts it (id or name), else the+ // active one. `layer.layerStyle.clear` needs no case: it leaves no effects, so nothing expands.let new_fx_target = if id.starts_with("layer.layerStyle.") {+ let target = crate::commands::layer_param(self, ¶ms).ok();self.active().and_then(|st| {- let target = params.get("layer").and_then(Value::as_u64).map(LayerId).or(st.active_layer)?;+ let target = target?;(st.doc.layer(target)?.effects.items.is_empty()).then_some((st.doc.id, target))})} else {diff --git a/crates/engine/src/layer_multi_cmds.rs b/crates/engine/src/layer_multi_cmds.rsindex 1ab67610d..a87c4badd 100644--- a/crates/engine/src/layer_multi_cmds.rs+++ b/crates/engine/src/layer_multi_cmds.rs@@ -2987,4 +2987,18 @@ mod layers_panel_parity_tests {s.execute("layer.layerStyle.dropShadow", json!({"layer": target.0, "size": 5})).unwrap();assert!(s.active().unwrap().fx_collapsed.contains(&target));}++ /// The disclosure follows the layer the command changes, however the command names it: a+ /// layer given by name is not the active one.+ #[test]+ fn expand_new_effects_follows_a_layer_named_by_its_name() {+ let (mut s, ids) = new_session();+ option(&mut s, "expandNewEffects", false);+ let (named, active) = (ids[0], ids[2]);+ assert_eq!(s.active().unwrap().active_layer, Some(active));+ s.execute("layer.layerStyle.dropShadow", json!({"layer": "Test 0", "size": 2})).unwrap();+ assert!(s.active().unwrap().doc.layer(named).is_some_and(|l| !l.effects.items.is_empty()));+ assert!(s.active().unwrap().fx_collapsed.contains(&named), "the named layer's new effects start collapsed");+ assert!(!s.active().unwrap().fx_collapsed.contains(&active), "the active layer is not the one changed");+ }}