From f715b9a1a59e966541d9e2c184b7e91aa8446f8d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 28 Oct 2026 04:04:16 -0700 Subject: [PATCH] Object: Lock, Hide, Unlock All and Show All are off in an object isolated inside pattern or opacity mask editing Pattern editing mode and opacity mask editing allow these commands only while their own layer is the isolated one. --- crates/engine/src/cmd.rs | 10 ++++------ crates/engine/src/tests/menucmds.rs | 4 ++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 96a86ac0e..6b658da0d 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -181,14 +181,12 @@ pub fn has_multi(s: &Session) -> std::result::Result<(), String> { } /// A document is open and it is not in isolation mode: Object › Lock's and Object › Hide's items, /// Unlock All and Show All are off in isolation mode. Pattern editing mode and opacity mask -/// editing isolate their art too, and do not count as isolation mode here. +/// editing isolate their art too, and do not count as isolation mode here while their own layer +/// is the isolated one. An object isolated inside them counts. pub fn outside_isolation(s: &Session) -> std::result::Result<(), String> { let st = s.active().ok_or("no document open")?; - if st.isolation.is_some() && st.doc.pattern_edit.is_none() && st.doc.mask_edit.is_none() { - Err("exit isolation mode first".into()) - } else { - Ok(()) - } + let editing_layer = |l| st.doc.pattern_edit.as_ref().is_some_and(|e| e.layer == l) || st.doc.mask_edit.as_ref().is_some_and(|e| e.layer == l); + if st.isolation.is_some_and(|l| !editing_layer(l)) { Err("exit isolation mode first".into()) } else { Ok(()) } } /// Objects are selected ([`has_selection`]) and the document is not in isolation mode /// ([`outside_isolation`]). diff --git a/crates/engine/src/tests/menucmds.rs b/crates/engine/src/tests/menucmds.rs index 9957040d0..5c227c8aa 100644 --- a/crates/engine/src/tests/menucmds.rs +++ b/crates/engine/src/tests/menucmds.rs @@ -381,6 +381,10 @@ fn unlock_all_and_show_all_are_off_in_isolation_mode() { assert!(!node(&s, tile[0]).visible, "hidden in pattern editing mode"); s.execute("object.showAll", &json!({})).unwrap(); assert!(node(&s, tile[0]).visible, "shown in pattern editing mode"); + // An object isolated inside pattern editing mode is isolation mode again. + s.execute("object.isolate", &json!({"id": tile[0].0})).unwrap(); + sel(&mut s, &[tile[0]]); + off_in_isolation(&mut s, &["object.unlockAll", "object.showAll"]); s.execute("object.pattern.cancel", &json!({})).unwrap(); // Opacity mask editing: the mask's art locks and unlocks again.