VectorCraft: An open-source, vector art tool written by scratch in pure Rust
object.isolate: an id that doesn't exist is reported as such
bflatasticec38b00a22f0
diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rsindex 7de994ed0..f5f59169c 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<Value> {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.rsindex 56a0a0093..ad1bda900 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]