mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-11 16:33:22 -06:00
Appearance: effect.apply reports the active row's object, and an empty aligned target list is an error
effect.apply now reports the item of the first selected object, whose row the active item is. With nothing selected, an explicit aligned item returns the command's error instead of an internal error.
This commit is contained in:
@@ -219,8 +219,9 @@ pub(crate) fn apply(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
index = fx.len() - 1;
|
||||
true
|
||||
})?;
|
||||
// The item the effect landed on in the first object (the active item applies where it fits).
|
||||
let first = ids.first().and_then(|id| s.doc().ok()?.doc.node(*id));
|
||||
// The item the effect landed on in the object whose row the item is (the first selected object
|
||||
// for the active item, which applies where it fits).
|
||||
let first = ids.get(item.anchor(s, &ids)).and_then(|id| s.doc().ok()?.doc.node(*id));
|
||||
let landed = first.and_then(|n| item.effects_item(&n.appearance, C).ok().flatten());
|
||||
Ok(json!({ "ids": ids_json(&ids), "index": index, "item": landed }))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user