From 30ead6b0ca1110f5411e0624d5a495fc9ce403cd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 16:41:08 -0800 Subject: [PATCH] Tests: "vectorize" checks label words for trace and a place in the first five The check for the results above the image trace commands matched any label containing the letters "trac", so labels such as Highlight Tracking or Subtract passed it. It now splits the label into words with the search's own word rules and accepts a word that is "trace" or stems to it (Tracing, Traced, Traces). The first image trace command must also be in the first five results. --- crates/ui-egui/src/palette/search.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/palette/search.rs b/crates/ui-egui/src/palette/search.rs index aed70389d0..71c2a7fd3b 100644 --- a/crates/ui-egui/src/palette/search.rs +++ b/crates/ui-egui/src/palette/search.rs @@ -1380,12 +1380,16 @@ mod tests { assert_eq!(first("outline text"), "type.createOutlines"); assert!(within("flip", "object.reflect", 3), "{:?}", ranked(&c, "flip")); assert!(within("combine", "object.pathfinder.unite", 3), "{:?}", ranked(&c, "combine")); - // "vectorize" finds the image trace commands, and only results whose label holds a form of - // "trace" rank above them. + // "vectorize" lists an image trace command in the first five, and only results whose label + // holds a word that is "trace" or stems to it rank above it. let vectorize = ranked(&c, "vectorize"); - let traced = |id: &String| c.list.iter().any(|e| &e.id == id && split_name(&e.shown).0.to_lowercase().contains("trac")); + let trace_word = |w: &str| { + let w = w.to_lowercase(); + w == "trace" || stems(&w).iter().any(|s| s == "trace") + }; + let traced = |id: &String| c.list.iter().any(|e| &e.id == id && words(split_name(&e.shown).0).any(trace_word)); let traces = vectorize.iter().position(|id| id.starts_with("imageTrace.")); - assert!(traces.is_some_and(|p| vectorize.get(..p).is_some_and(|above| above.iter().all(traced))), "{vectorize:?}"); + assert!(traces.is_some_and(|p| p < 5 && vectorize.get(..p).is_some_and(|above| above.iter().all(traced))), "{vectorize:?}"); assert_eq!(first("colour"), "panel:color", "{:?}", ranked(&c, "colour")); // A word that only starts other labels is in a group, and its labels follow the direct match. assert_eq!(first("unite"), "object.pathfinder.unite");