diff --git a/crates/engine/src/assets/library/tests.rs b/crates/engine/src/assets/library/tests.rs index e9b6009ca..733c3ba8c 100644 --- a/crates/engine/src/assets/library/tests.rs +++ b/crates/engine/src/assets/library/tests.rs @@ -458,6 +458,11 @@ fn going_to_a_library_main_opens_the_library_file() { let e = s.execute("component.goToMain", &json!({"id": card})).unwrap_err(); assert!(e.to_string().contains("isn't at"), "{e}"); assert_eq!(s.docs.len(), 1); + + let NodeKind::Instance { component: copy, .. } = node(&s, card).kind else { panic!("not an instance") }; + s.doc_mut().unwrap().libraries_mut().components.retain(|r| r.root != copy); + let e = s.execute("component.goToMain", &json!({"id": card})).unwrap_err(); + assert!(e.to_string().contains("no link to its library"), "an imported copy without its record: {e}"); let _ = std::fs::remove_dir_all(&d); } diff --git a/crates/engine/src/cmd/component.rs b/crates/engine/src/cmd/component.rs index 7288045ad..e0b2e02f4 100644 --- a/crates/engine/src/cmd/component.rs +++ b/crates/engine/src/cmd/component.rs @@ -207,6 +207,13 @@ pub fn specs() -> Vec { let library = library.to_string(); return go_to_library_main(s, &library, &name, key); } + if doc.is_remote(component) { + return Err(EngineError::Disabled( + cmd.into(), + "the main component is a library copy with no link to its library (it came with an imported file): enable that library to reach it" + .into(), + )); + } super::edit::select_and_page(s, vec![component])?; let ds = s.ds_mut()?; if let Some(b) = ds.doc.world_bounds(component) {