diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rs index 7de994ed..f5f59169 100644 --- a/crates/engine/src/cmd/object.rs +++ b/crates/engine/src/cmd/object.rs @@ -859,7 +859,7 @@ fn isolate(s: &mut Session, p: &Value) -> Result { let st = s.doc_mut()?; // Groups, layers and single objects (a path, a compound path, an image…); type isn't // isolated: a double-click on it edits its text. - if st.doc.node(id).is_none_or(|n| matches!(n.kind, NodeKind::Text(_))) { + if matches!(st.doc.node(id).ok_or(EngineError::NoNode(id))?.kind, NodeKind::Text(_)) { return Err(bad("object.isolate", "type objects can't be isolated")); } let isolation = st.doc.node(id).filter(|n| n.extras().shaper.is_some()).and_then(|n| n.children()).and_then(|c| c.first()).map_or(id, |n| n.id); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 56a0a009..ad1bda90 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -1595,6 +1595,14 @@ fn inspect_reports_a_compound_paths_paint_and_blend_modes() { assert!(group["blend"] == "Multiply" && group.get("fill").is_none(), "{group}"); } +#[test] +fn isolating_an_object_that_doesnt_exist_says_so() { + let mut s = session(); + let e = s.execute("object.isolate", &json!({"id": 999_999})).unwrap_err(); + assert_eq!(e.to_string(), EngineError::NoNode(NodeId(999_999)).to_string()); + assert!(!e.to_string().contains("type"), "{e}"); +} + /// `depth` and `childLimit` slice a summary read; a level that shows fewer children /// than it has reports `childCount`, and invalid values are rejected, not reinterpreted. #[test]