mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-01 13:47:21 -06:00
Global Edit: the menu checks a selected group's kind only; its contents are checked on start
This commit is contained in:
@@ -357,7 +357,10 @@ fn can_toggle(s: &Session) -> std::result::Result<(), String> {
|
||||
let [id] = st.selection.objects.as_slice() else {
|
||||
return Err(if st.selection.is_empty() { "nothing selected" } else { "select one object" }.into());
|
||||
};
|
||||
// A group's contents are checked when Global Edit starts: building its shape here would walk
|
||||
// every object in it each time the menu or the Properties panel asks.
|
||||
match st.doc.node(*id) {
|
||||
Some(n) if n.extras().mask.is_none() && plain_group(n) => Ok(()),
|
||||
Some(n) if supported(n) => Ok(()),
|
||||
_ => Err(UNSUPPORTED.into()),
|
||||
}
|
||||
|
||||
@@ -295,8 +295,10 @@ fn global_edit_needs_one_supported_object() {
|
||||
};
|
||||
let (g, _) = (group(&mut s, 600.0), group(&mut s, 700.0));
|
||||
sel(&mut s, &[g]);
|
||||
// The menu only checks that it is a group; starting refuses its contents.
|
||||
let e = s.execute("select.globalEdit", &json!({})).unwrap_err();
|
||||
assert!(matches!(e, EngineError::Disabled(..)) && e.to_string().contains("symbol instances and groups of them"), "{e}");
|
||||
assert!(e.to_string().contains("symbol instances and groups of them"), "{e}");
|
||||
assert!(s.doc().unwrap().global_edit.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user