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:
dotCooCoo
2026-10-31 23:29:35 +07:00
committed by bflatastic
parent a32d6364ec
commit f9e78eb144
3 changed files with 14 additions and 3 deletions
+3 -2
View File
@@ -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 }))
}