diff --git a/crates/engine/src/al_behaviour_tests.rs b/crates/engine/src/al_behaviour_tests.rs index e9f2ea86f..030b30cfe 100644 --- a/crates/engine/src/al_behaviour_tests.rs +++ b/crates/engine/src/al_behaviour_tests.rs @@ -267,7 +267,9 @@ fn auto_layout_keys_beside_no_auto_layout_are_refused() { assert!(e.contains("turns auto layout off"), "{props}: {e}"); } let e = s.execute("node.set", &json!({"id": f, "props": {"layout": null, "gap": 8, "padding": 4}})).unwrap_err().to_string(); - assert!(e.contains("`gap`, `padding` are auto layout properties"), "{e}"); + assert!(e.contains("`gap`, `padding` are auto layout properties, and `layout` in the same call"), "{e}"); + let e = s.execute("node.set", &json!({"id": f, "props": {"layoutMode": "NONE", "wrap": true}})).unwrap_err().to_string(); + assert!(e.contains("`wrap` is an auto layout property, and `layoutMode` in the same call"), "{e}"); // Without other auto layout keys, `layout: null` still removes it. set(&mut s, f, json!({"layout": "vertical", "gap": 8})); set(&mut s, f, json!({"layout": null, "name": "Plain"})); diff --git a/crates/engine/src/cmd/props.rs b/crates/engine/src/cmd/props.rs index e0cb996eb..d570e822f 100644 --- a/crates/engine/src/cmd/props.rs +++ b/crates/engine/src/cmd/props.rs @@ -403,15 +403,12 @@ fn apply_order(k: &str) -> u8 { /// would turn it back on (`layout_mut`), so the call is refused rather than one of them losing. fn layout_keys_beside_none(cmd: &str, props: &Map) -> Result<()> { let off = ["layout", "layoutMode"] - .iter() - .filter_map(|k| props.get(*k)) - .any(|v| v.is_null() || v.as_str().is_some_and(|s| s.eq_ignore_ascii_case("none"))); + .into_iter() + .find(|k| props.get(*k).is_some_and(|v| v.is_null() || v.as_str().is_some_and(|s| s.eq_ignore_ascii_case("none")))); let tuning: Vec = props.keys().filter(|k| LAYOUT_KEYS.contains(&k.as_str())).map(|k| format!("`{k}`")).collect(); - if !off || tuning.is_empty() { - return Ok(()); - } + let Some(off) = off.filter(|_| !tuning.is_empty()) else { return Ok(()) }; let (what, are) = if tuning.len() == 1 { ("an auto layout property", "is") } else { ("auto layout properties", "are") }; - Err(bad(cmd, format!("{} {are} {what}, and `layout` in the same call turns auto layout off", tuning.join(", ")))) + Err(bad(cmd, format!("{} {are} {what}, and `{off}` in the same call turns auto layout off", tuning.join(", ")))) } /// An explicit width (`is_w`) or height makes hugging or filling on that axis fixed, like typing