From 0d7c6dd6e21359389c780e06c5662954a016fcc3 Mon Sep 17 00:00:00 2001 From: HassanKhan Date: Tue, 10 Nov 2026 10:48:52 +0500 Subject: [PATCH] Spelling right-click: Intertwine members by their tier at the point (part of #4936) --- crates/ui-egui/src/canvas/tool_overlays.rs | 25 +++++++++----- crates/ui-egui/src/tests/contextmenu.rs | 40 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/canvas/tool_overlays.rs b/crates/ui-egui/src/canvas/tool_overlays.rs index 0151b35582..67f6ac861a 100644 --- a/crates/ui-egui/src/canvas/tool_overlays.rs +++ b/crates/ui-egui/src/canvas/tool_overlays.rs @@ -175,18 +175,25 @@ pub(crate) fn misspelled_word_at(app: &mut VectorcraftApp, p: Point) -> Option = None; - fn walk<'a>(nodes: &'a [std::sync::Arc], locked: bool, f: &mut impl FnMut(&'a Node, bool)) { + let mut top: Option<(vectorcraft_doc::NodeId, bool)> = None; + // Back to front as drawn at `p`: an Intertwine group's members by their tier there, those of + // one tier in their stacking order ([`vectorcraft_doc::intertwine`]). + fn walk(nodes: &[std::sync::Arc], p: Point, locked: bool, f: &mut impl FnMut(&Node, bool)) { for n in nodes.iter().filter(|n| n.visible) { let locked = locked || n.locked; f(n, locked); - if let Some(children) = n.children() { - walk(children, locked, f); + let Some(children) = n.children() else { continue }; + if matches!(n.kind, NodeKind::Intertwine { .. }) { + let mut drawn = children.to_vec(); + drawn.sort_by_key(|c| vectorcraft_doc::intertwine::tier_at(c, p)); + walk(&drawn, p, locked, f); + } else { + walk(children, p, locked, f); } } } - // Paint order: a later hit is on top. - walk(&st.doc.layers, false, &mut |n, locked| { + // A later hit is on top. + walk(&st.doc.layers, p, false, &mut |n, locked| { let NodeKind::Text(tx) = &n.kind else { return }; if n.geometric_bounds().is_none_or(|b| !b.contains(p)) { return; @@ -194,10 +201,11 @@ pub(crate) fn misspelled_word_at(app: &mut VectorcraftApp, p: Point) -> Option Option