diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index 700c045d3f..5cdefd559a 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -1380,11 +1380,17 @@ fn object_behind(cx: &ToolContext, p: Point) -> Option { /// 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 { 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)) } diff --git a/crates/tools/src/select/tests.rs b/crates/tools/src/select/tests.rs index a8e1f8acee..d7ff7a3a90 100644 --- a/crates/tools/src/select/tests.rs +++ b/crates/tools/src/select/tests.rs @@ -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:?}"); }