Selection: a press on a group member with every anchor selected moves it

select.anchors and select.key leave a path with all of its anchors in the
selection's anchor map. The Selection tool's check for a selected member
under the pointer read any anchor entry as a partial selection, so a press
on such a member selected the outer group instead of moving the member.

The check now counts a member as selected whole when its anchor entry
holds every anchor of the path.
This commit is contained in:
dotCooCoo committed 2026-11-18 01:38:48 -08:00
1 parent 72190d6998
commit 60ecfd7aed
2 files changed
+15 -1

No files matched your search

+7 -1
View File
@@ -1380,11 +1380,17 @@ fn object_behind(cx: &ToolContext, p: Point) -> Option<NodeId> {
/// object selected whole between it and the art under the pointer, such as members of a group
/// picked with Group Selection. A press there keeps the selection and a drag moves it (#8047). A
/// member with only some anchors or segments selected does not count: the press selects `top`.
/// A member with every anchor selected (as `select.anchors` and `select.key` leave a path) counts.
fn selected_under(cx: &ToolContext, h: &Hit, top: NodeId) -> Option<NodeId> {
if cx.selection.contains(top) {
return Some(top);
}
let whole = |id: NodeId| cx.selection.contains(id) && cx.selection.partial(id).is_none() && !cx.selection.segments.contains_key(&id);
let every_anchor = |id: NodeId| {
cx.selection
.partial(id)
.is_none_or(|picked| cx.doc.node(id).and_then(|n| n.path_data()).is_some_and(|p| p.anchors().all(|(s, i, _)| picked.contains(&(s, i)))))
};
let whole = |id: NodeId| cx.selection.contains(id) && every_anchor(id) && !cx.selection.segments.contains_key(&id);
let below = h.ancestry.iter().position(|id| *id == top).map_or(&[][..], |i| h.ancestry.get(i..).unwrap_or_default());
below.iter().copied().chain(std::iter::once(h.leaf)).find(|id| whole(*id))
}
+8
View File
@@ -2829,4 +2829,12 @@ fn a_press_on_a_selected_member_of_a_group_moves_the_selected_members() {
let c = cx(&d, &s, &p);
let down = SelectionTool::default().pointer(&c, &ev(PointerKind::Down, 125.0, 125.0));
assert_eq!(down, vec![Action::Exec("select.set".into(), json!({"ids": [outer.0]}))]);
// Every anchor of the member picked (as `select.anchors` and `select.key` leave it) selects
// it whole: the press moves it.
s.anchors.insert(a, [(0, 0), (0, 1), (0, 2), (0, 3)].into_iter().collect());
let c = cx(&d, &s, &p);
let mut t = SelectionTool::default();
assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::Move, "every anchor");
let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 125.0));
assert!(!is_select(&down), "every anchor: {down:?}");
}