object.isolate: an id that doesn't exist is reported as such

This commit is contained in:
bflatastic 2026-10-12 19:37:45 +07:00
parent d6bace14c3
commit ec38b00a22
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -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]