From bc49cf5038847d78d7e35af16dab2bed055edc1c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 20:16:54 -0800 Subject: [PATCH 1/5] Rerun CI From a098e71ecf2a122d56ec3a02fe59be3f320a0e33 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 01:23:39 -0800 Subject: [PATCH 2/5] Command Palette: stem forms of group words and backtick spans in descriptions A query word that is a stem form of a word of a group of the same meaning ("setting" of settings) now finds the group, and a stem form of a group word ("setting") now meets a result's word, so "prefs" finds Zz Setting. The description reader skips spans between backticks as the engine's params object does, so `{pattern?: `(`} transparent background` reads as "transparent background". The shortcut editor's required-field check keeps reading only double quotes. --- crates/ui-egui/src/palette/search.rs | 51 ++++++++++++++++++++++----- crates/ui-egui/src/shortcut_editor.rs | 23 +++++++++--- 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/palette/search.rs b/crates/ui-egui/src/palette/search.rs index 7fe8fc09be..51248ac156 100644 --- a/crates/ui-egui/src/palette/search.rs +++ b/crates/ui-egui/src/palette/search.rs @@ -84,8 +84,9 @@ pub(crate) struct Index { initials_text: String, /// Each result's offset and length in `initials_text`. initials: Vec<(u32, u16)>, - /// Each word of a group of words with the same meaning ([`super::words::GROUPS`], and the - /// words the UI language's catalog adds), with the group's place in the table. + /// Each word of a group of words with the same meaning ([`super::words::GROUPS`], the words the + /// UI language's catalog adds and the stem forms of the table's words), with the group's place + /// in the table. synonyms: HashMap, u16>, } @@ -96,8 +97,10 @@ pub(crate) fn is_one_word(w: &str) -> bool { } /// The words of each group of [`super::words::GROUPS`], with the words `search_row` gives for the -/// group's catalog row ([`super::words::row_key`]) in the UI language. A word the catalog gives -/// that is not a single word, or that is already a word of a group, is left out. +/// group's catalog row ([`super::words::row_key`]) in the UI language, and then the English stem +/// forms ([`stems`]) of each word of [`super::words::GROUPS`] ("setting" of settings). A word the +/// catalog gives that is not a single word, and a word or stem form that is already a word of a +/// group, is left out. fn synonym_groups(search_row: impl Fn(&str) -> Option) -> HashMap, u16> { let mut out: HashMap, u16> = HashMap::new(); let groups = super::words::GROUPS.iter().enumerate().filter_map(|(g, words)| u16::try_from(g).ok().map(|g| (g, words))); @@ -106,7 +109,7 @@ fn synonym_groups(search_row: impl Fn(&str) -> Option) -> HashMap Option) -> HashMap (&str, &str) { } /// A command's description, read from its params text: the text without each `{…}` group that is -/// not inside a `{`, `[` or `(` group (braces inside double quotes are text), without each such +/// not inside a `{`, `[` or `(` group (brackets inside double quotes or backticks are text, as in +/// the engine's params object), without each such /// `[…]` or `(…)` group just after a `→`, and without the `→` just before a removed group, with /// each run of whitespace made one space and cut to its first [`DESCRIPTION_CHARS`] characters at /// the end of a word. A group that is never closed stays in the text, and so does a result written @@ -290,7 +301,7 @@ pub(crate) fn description(params: &str) -> String { let mut out = String::new(); // The end of the text copied to `out`, and whether a removed group is open. let (mut copied, mut open) = (0, false); - for (i, ch, depth) in crate::shortcut_editor::outside_quotes(params) { + for (i, ch, depth) in crate::shortcut_editor::outside_quotes_and_backticks(params) { let before = params.get(copied..i).unwrap_or_default(); match ch { '{' | '[' | '(' if depth == 0 && (ch == '{' || before.trim_end().ends_with('→')) => { @@ -530,7 +541,8 @@ impl Index { } /// The other words of the group of words with the same meaning that `word`, or a stem form of - /// it, is in ("bg" and background, "flipped" and reflect), as places in `terms`; the words of the + /// it, is in ("bg" and background, "flipped" and reflect, "setting" and preferences), with the + /// stem forms of the group's words ("prefs" and setting), as places in `terms`; the words of the /// group no result holds are left out. fn synonyms_of(&self, word: &str) -> Vec { let group = std::iter::once(word.to_string()).chain(stems(word)).find_map(|w| self.synonyms.get(w.as_str()).copied()); @@ -1215,6 +1227,24 @@ mod tests { assert_eq!(ranked(&c, "colour"), ["c.three", "panel:color", "tool:zz"]); } + /// A query word that is an English stem form of a word of a group ("setting" of settings, + /// "preference" of preferences) finds the group, and a stem form of a word of the group meets a + /// result's word ("prefs" and Zz Setting). A result whose label holds the query word itself + /// still ranks first. + #[test] + fn a_stem_form_of_a_group_word_meets_the_group() { + let c = synthetic(vec![entry("Zz Preferences", "a.one"), entry("Zz Setting", "b.two"), entry("Zz Settings", "c.three")]); + let setting = ranked(&c, "setting"); + assert_eq!(setting.first().map(String::as_str), Some("b.two"), "{setting:?}"); + assert!(setting.iter().any(|id| id == "a.one"), "{setting:?}"); + assert!(ranked(&c, "preference").iter().any(|id| id == "c.three"), "a singular query word finds the group"); + let prefs = ranked(&c, "prefs"); + for id in ["a.one", "b.two", "c.three"] { + assert!(prefs.iter().any(|r| r == id), "{id} in {prefs:?}"); + } + assert!(ranked(&c, "set").iter().all(|id| id != "a.one"), "a stem form of a query word that is no group word finds no group"); + } + /// A catalog row adds words in the UI language to a group, and a word that is not a single word /// or that is a word of another group is left out. #[test] @@ -1255,6 +1285,11 @@ mod tests { // A group inside parentheses is text, and so is a group that is never closed. ("fits it (as {x} does) here", "fits it (as {x} does) here"), ("{a: 1 never closed", "{a: 1 never closed"), + // A bracket or a double quote inside a backtick span is text, as in the engine's params + // object, and so is a group inside a backtick span outside a group. + ("{pattern?: `(`} transparent background", "transparent background"), + ("{sep: `}`, quote: `\"`} split the text", "split the text"), + ("uses `{x}` as text", "uses `{x}` as text"), // No group at all. ("plain words\n here", "plain words here"), ("", ""), diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index e6120ad599..a0af8b082b 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -1037,13 +1037,28 @@ fn names_a_required_field(params: &str) -> bool { /// offset and the number of `{`, `[` and `(` groups open before it. A closing `}`, `]` or `)` comes /// with a count that includes the group it closes, and one with no group open counts none. pub(crate) fn outside_quotes(text: &str) -> impl Iterator + '_ { - let (mut depth, mut quoted) = (0usize, false); + outside_marks(text, &['"']) +} + +/// [`outside_quotes`], with a span between backticks skipped as well, as the engine's params object +/// reads it: inside a span opened by a double quote or a backtick, only the same mark closes it. +pub(crate) fn outside_quotes_and_backticks(text: &str) -> impl Iterator + '_ { + outside_marks(text, &['"', '`']) +} + +/// Each character of `text` that is not one of `marks` or inside a span a mark opens and the same +/// mark closes, as [`outside_quotes`] counts them. +fn outside_marks<'a>(text: &'a str, marks: &'static [char]) -> impl Iterator + 'a { + let (mut depth, mut quote) = (0usize, None::); text.char_indices().filter_map(move |(i, ch)| { - if ch == '"' { - quoted = !quoted; + if let Some(q) = quote { + if ch == q { + quote = None; + } return None; } - if quoted { + if marks.contains(&ch) { + quote = Some(ch); return None; } let before = depth; From 53e2b49fb08116d3945b097683e188f641fb441d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 01:55:46 -0800 Subject: [PATCH 3/5] Command Palette: a synonym match reads the label's own word before its stem A query word of a group of words with the same meaning ("prefs") is read with the group word the result's label or menu path holds before a stem form of that word, so Preferences keeps the exact-label tier and ranks above Preferences Tool. The stem form is still used when the label holds only that form ("prefs" and Zz Setting). --- crates/ui-egui/src/palette/search.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/palette/search.rs b/crates/ui-egui/src/palette/search.rs index 51248ac156..d88249cdb7 100644 --- a/crates/ui-egui/src/palette/search.rs +++ b/crates/ui-egui/src/palette/search.rs @@ -774,14 +774,16 @@ pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str) -> Vec { splice(&mut meant, &mut meant_copied, k, token, near); } } - let fields: &[u8] = match g { - LABEL_SYNONYM => &[LABEL, LABEL_STEMMED], - PATH_SYNONYM => &[PATH, PATH_STEMMED], + // A word of the group the label or menu path holds comes before a stem form of one, so + // "prefs" reads Preferences as preferences and not as its stem form preference. + let fields: &[&[u8]] = match g { + LABEL_SYNONYM => &[&[LABEL], &[LABEL_STEMMED]], + PATH_SYNONYM => &[&[PATH], &[PATH_STEMMED]], _ => &[], }; if !fields.is_empty() { synonym = true; - if let Some(same) = meanings.get(k).and_then(|same| index.nearest_of(same, i, fields)) { + if let Some(same) = meanings.get(k).and_then(|same| fields.iter().find_map(|f| index.nearest_of(same, i, f))) { splice(&mut meant, &mut meant_copied, k, token, same); } } @@ -1230,9 +1232,12 @@ mod tests { /// A query word that is an English stem form of a word of a group ("setting" of settings, /// "preference" of preferences) finds the group, and a stem form of a word of the group meets a /// result's word ("prefs" and Zz Setting). A result whose label holds the query word itself - /// still ranks first. + /// still ranks first. The whole query is read with the group word a label holds before a stem + /// form of it, so "prefs" reads Preferences as its exact label. #[test] fn a_stem_form_of_a_group_word_meets_the_group() { + let c = synthetic(vec![entry("Preferences Tool", "tool:zz"), entry("Preferences", "a.one")]); + assert_eq!(ranked(&c, "prefs"), ["a.one", "tool:zz"]); let c = synthetic(vec![entry("Zz Preferences", "a.one"), entry("Zz Setting", "b.two"), entry("Zz Settings", "c.three")]); let setting = ranked(&c, "setting"); assert_eq!(setting.first().map(String::as_str), Some("b.two"), "{setting:?}"); From 8cc6b074b9fe77c6af9aa442ccac35d5434efcee Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 06:16:55 -0800 Subject: [PATCH 4/5] Command Palette: a word two search rows of one catalog add is reported The i18n test of the `search` rows now also checks that no two rows of one catalog add the same word. Such a word was given to only the first row's group, so a search for it did not find results through the other group. --- crates/ui-egui/src/i18n/tests.rs | 9 +++++--- crates/ui-egui/src/palette/words.rs | 33 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 1ef955c627..46805d66dc 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -805,16 +805,19 @@ fn anti_aliasing_method_labels_are_in_complete_catalogs() { } /// Each row in the `search` context, which adds a language's words to a group of words with the same -/// meaning for the command palette, names a group and adds single words of no other group. No -/// catalog has to have these rows. +/// meaning for the command palette, names a group and adds single words of no other group, and no +/// two rows of one catalog add the same word. No catalog has to have these rows. #[test] fn search_rows_name_a_group_and_add_single_words() { let mut bad = Vec::new(); for l in LANGUAGES.iter().filter(|l| !l.source.is_empty()) { let (entries, _) = parse_entries(l.source); - for (_, src, tr) in entries.iter().filter(|(ctx, _, _)| ctx == crate::palette::words::CONTEXT) { + let rows: Vec<(&str, &str)> = + entries.iter().filter(|(ctx, _, _)| ctx == crate::palette::words::CONTEXT).map(|(_, src, tr)| (src.as_str(), tr.as_str())).collect(); + for &(src, tr) in &rows { bad.extend(crate::palette::words::row_problems(src, tr).into_iter().map(|p| format!("{}: {p}", l.code))); } + bad.extend(crate::palette::words::shared_row_words(&rows).into_iter().map(|p| format!("{}: {p}", l.code))); } assert!(bad.is_empty(), "{bad:#?}"); } diff --git a/crates/ui-egui/src/palette/words.rs b/crates/ui-egui/src/palette/words.rs index 44176dbd24..4ef6248c6a 100644 --- a/crates/ui-egui/src/palette/words.rs +++ b/crates/ui-egui/src/palette/words.rs @@ -91,6 +91,29 @@ pub(crate) fn row_problems(source: &str, text: &str) -> Vec { problems } +/// The words that more than one of a catalog's `search` rows, given as `(source, text)`, add, each +/// with the first two rows that add it. +#[cfg(test)] +pub(crate) fn shared_row_words(rows: &[(&str, &str)]) -> Vec { + let mut first: std::collections::HashMap = std::collections::HashMap::new(); + let mut problems = vec![]; + for &(source, text) in rows { + for (w, single) in row_words(text) { + if !single { + continue; + } + match first.get(&w) { + Some(&other) if other != source => problems.push(format!("{w:?} is a word of {other:?} and {source:?}")), + Some(_) => {} + None => { + first.insert(w, source); + } + } + } + } + problems +} + #[cfg(test)] mod tests { use super::*; @@ -122,4 +145,14 @@ mod tests { assert_eq!(row_problems("remove, delete, erase, clear", "ganz entfernen").len(), 1, "two words"); assert_eq!(row_problems("remove, delete, erase, clear", "Text").len(), 1, "a word of another group once lowercased"); } + + /// A word that two `search` rows of one catalog add is reported; a word repeated in one row is not. + #[test] + fn a_word_in_two_rows_of_a_catalog_is_reported() { + let remove = "remove, delete, erase, clear"; + let image = "image, picture, photo, img, bitmap"; + assert!(shared_row_words(&[(remove, "entfernen, löschen"), (image, "bild, foto")]).is_empty()); + assert!(shared_row_words(&[(remove, "entfernen, Entfernen")]).is_empty(), "one row"); + assert_eq!(shared_row_words(&[(remove, "entfernen, löschen"), (image, "Bild, Löschen")]).len(), 1); + } } From 3b8afe1770a081ceafa3b11589c39d4b736b324f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 14:05:32 -0800 Subject: [PATCH 5/5] Command Palette: a synonym reads as the group word that fits the whole query When a label holds two words of the group a query word means, the whole query is now read with the one that matches it best, so "prefs preferences" finds Settings Preferences by its exact label. A query word that only descriptions hold meets the stem forms of descriptions only and no longer changes how labels and menu paths rank. The index timing test collects the params text before its timer. --- crates/ui-egui/src/palette/search.rs | 124 +++++++++++++++++++++------ 1 file changed, 99 insertions(+), 25 deletions(-) diff --git a/crates/ui-egui/src/palette/search.rs b/crates/ui-egui/src/palette/search.rs index 4ca246cb59..312c77e73a 100644 --- a/crates/ui-egui/src/palette/search.rs +++ b/crates/ui-egui/src/palette/search.rs @@ -502,14 +502,17 @@ impl Index { // The word meets a stem form of a word of the result ("scale" and Scaling) when it is itself // a word of some result's label, menu path, id or description, so a partly typed word // ("scal") that only equals a stem form does not lift Scaling above Scale. A description is - // cut at the end of a word ([`description`]), so it holds no partly typed word. - if let Some(t) = self.find(word) - && self.postings_of(t).iter().any(|p| matches!(p.field, LABEL | PATH | ID | DESCRIPTION)) - { - mark(self.postings_of(t), &|field| match field { - LABEL_STEMMED => Some(LABEL_STEM), - PATH_STEMMED => Some(PATH_WORD), - DESCRIPTION_STEMMED => Some(DESCRIPTION_WORD), + // cut at the end of a word ([`description`]), so it holds no partly typed word. A word that + // only descriptions hold meets the stem forms of descriptions only, so it does not change + // how labels and menu paths rank. + if let Some(t) = self.find(word) { + let postings = self.postings_of(t); + let named = postings.iter().any(|p| matches!(p.field, LABEL | PATH | ID)); + let described = named || postings.iter().any(|p| p.field == DESCRIPTION); + mark(postings, &|field| match field { + LABEL_STEMMED if named => Some(LABEL_STEM), + PATH_STEMMED if named => Some(PATH_WORD), + DESCRIPTION_STEMMED if described => Some(DESCRIPTION_WORD), _ => None, }); } @@ -603,6 +606,15 @@ impl Index { self.terms.get(*t).map(|at| self.text(at)) } + /// The texts of the words of `near` that are words of result `i` in one of `fields`, in the + /// order of `near`. + fn words_of(&self, near: &[usize], i: usize, fields: &[u8]) -> Vec<&str> { + near.iter() + .filter(|&&t| self.postings_of(t).iter().any(|p| usize::from(p.entry) == i && fields.contains(&p.field))) + .filter_map(|&t| self.terms.get(t).map(|at| self.text(at))) + .collect() + } + /// Is `query` (no spaces) the initials of one of result `i`'s labels? fn initials_are(&self, i: usize, query: &str) -> bool { let Some(&(offset, len)) = self.initials.get(i) else { return false }; @@ -674,7 +686,8 @@ type RankKey = (bool, bool, u8, u8, u32, u8, u8, usize); /// whole-query match is read with each such word replaced by the word it is a typo of ("gruop" as /// "group"). Results are ordered by that, by how the whole query matches ([`phrase`]), then by the /// worst grade a word gets, the sum of the grades, how the whole query matches when read with each -/// word matched through a word of the same meaning replaced by that word ("colour" as "color"), +/// word matched through a word of the same meaning replaced by that word ("colour" as "color"; of +/// several such words the result holds, the ones that match the whole query best), /// the kind of result ([`kind`]), the label's length and the catalog order. An empty query lists /// every result in catalog order. pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str) -> Vec { @@ -739,7 +752,8 @@ pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str) -> Vec { // through a word with the same meaning replaced by that word too. let (mut typo, mut corrected, mut copied) = (false, String::new(), 0); let mut described = false; - let (mut synonym, mut meant, mut meant_copied) = (false, String::new(), 0); + // The words each such word may be read as, by its place in the query. + let (mut synonym, mut meant): (bool, Vec<(usize, Vec<&str>)>) = (false, vec![]); let splice = |out: &mut String, copied: &mut usize, k: usize, token: &str, word: &str| { if let Some(&start) = starts.get(k) && let Some(between) = query.get(*copied..start) @@ -775,20 +789,29 @@ pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str) -> Vec { typo = true; if let Some(near) = typos.get(k).and_then(|near| index.nearest_of(near, i, &[field])) { splice(&mut corrected, &mut copied, k, token, near); - splice(&mut meant, &mut meant_copied, k, token, near); + meant.push((k, vec![near])); } } - // A word of the group the label or menu path holds comes before a stem form of one, so - // "prefs" reads Preferences as preferences and not as its stem form preference. - let fields: &[&[u8]] = match g { - LABEL_SYNONYM => &[&[LABEL], &[LABEL_STEMMED]], - PATH_SYNONYM => &[&[PATH], &[PATH_STEMMED]], + // The word may be read as each word of its group the label or menu path holds, and then + // as each stem form of one, so "prefs" reads Preferences as preferences before its stem + // form preference; the reading that matches the whole query best counts. + let fields: &[u8] = match g { + LABEL_SYNONYM => &[LABEL, LABEL_STEMMED], + PATH_SYNONYM => &[PATH, PATH_STEMMED], _ => &[], }; if !fields.is_empty() { synonym = true; - if let Some(same) = meanings.get(k).and_then(|same| fields.iter().find_map(|f| index.nearest_of(same, i, f))) { - splice(&mut meant, &mut meant_copied, k, token, same); + let mut same: Vec<&str> = vec![]; + for &f in fields { + for w in meanings.get(k).map(|near| index.words_of(near, i, &[f])).unwrap_or_default() { + if !same.contains(&w) { + same.push(w); + } + } + } + if !same.is_empty() { + meant.push((k, same)); } } worst = worst.max(g); @@ -803,12 +826,7 @@ pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str) -> Vec { } else { phrase(e, &query, initials) }; - let meant_tier = if synonym { - meant.push_str(query.get(meant_copied..).unwrap_or_default()); - phrase(e, &meant, false) - } else { - tier - }; + let meant_tier = if synonym { best_reading(&query, &starts, &tokens, &meant, |read| phrase(e, read, false)) } else { tier }; let length = split_name(&e.shown).0.chars().count(); ranked.push(((described, typo, tier, worst, sum, meant_tier, e.kind, length), place)); } @@ -816,6 +834,39 @@ pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str) -> Vec { ranked.into_iter().map(|(_, place)| place).collect() } +/// The most readings of a query [`best_reading`] compares for one result. +const MAX_READINGS: usize = 16; + +/// The best whole-query match `tier` gives `query` read with each word `k` of `swaps` (the word at +/// `starts[k]`, as long as `tokens[k]`) replaced by one of its words. At most [`MAX_READINGS`] +/// readings are compared, the first one with each word's first choice. +fn best_reading(query: &str, starts: &[usize], tokens: &[&str], swaps: &[(usize, Vec<&str>)], tier: impl Fn(&str) -> u8) -> u8 { + let readings = swaps.iter().fold(1usize, |n, (_, words)| n.saturating_mul(words.len().max(1))).min(MAX_READINGS); + let (mut best, mut read) = (NO_PHRASE, String::new()); + for r in 0..readings { + read.clear(); + let (mut copied, mut rest) = (0, r); + for (k, words) in swaps { + let len = words.len().max(1); + let pick = words.get(rest % len); + rest /= len; + if let (Some(word), Some(&start), Some(token)) = (pick, starts.get(*k), tokens.get(*k)) + && let Some(between) = query.get(copied..start) + { + read.push_str(between); + read.push_str(word); + copied = start + token.len(); + } + } + read.push_str(query.get(copied..).unwrap_or_default()); + best = best.min(tier(&read)); + if best == EXACT_ID { + break; + } + } + best +} + /// The first place in the menu bar of each item a result runs, as an English `›`-separated path /// of the menus that hold it: by command id, `panel:` for a Window menu panel (Learn too), /// `effect:` for an Effect menu item and `plugin:` for an Object › Plug-ins filter. With @@ -1273,6 +1324,29 @@ mod tests { assert!(ranked(&c, "set").iter().all(|id| id != "a.one"), "a stem form of a query word that is no group word finds no group"); } + /// A query word that only a description holds meets the stem forms of descriptions, not those + /// of labels: "rat" in another command's description does not lift Zz Rating above Zz Ratio. + #[test] + fn a_description_word_does_not_lift_a_label_stem() { + let entries = || vec![entry("Zz Ratio", "a.one"), entry("Zz Rating", "b.two"), entry("Animal Outline", "c.three")]; + assert_eq!(ranked(&synthetic(entries()), "rat zz"), ["a.one", "b.two"]); + let c = described(entries(), &["", "", "Trace a rat silhouette"]); + assert_eq!(ranked(&c, "rat zz"), ["a.one", "b.two"]); + let c = described(vec![entry("Zz Outline", "a.one"), entry("Zz Trace", "b.two")], &["Scaling the art", "Scale it"]); + assert!(ranked(&c, "scale").iter().any(|id| id == "a.one"), "a description word still meets a description's stem form"); + } + + /// When a label holds two words of the group a query word means, the whole query is read with + /// the one that matches it best: "prefs preferences" reads Settings Preferences as its exact + /// label, which ranks it before a tool whose label holds only one of the words. + #[test] + fn a_synonym_is_read_as_the_group_word_that_matches_the_whole_query() { + let c = synthetic(vec![entry("Preferences Tool", "tool:zz"), entry("Settings Preferences", "a.one")]); + assert_eq!(ranked(&c, "prefs preferences").first().map(String::as_str), Some("a.one")); + let c = synthetic(vec![entry("Preferences Tool", "tool:zz"), entry("Preferences", "a.one")]); + assert_eq!(ranked(&c, "prefs"), ["a.one", "tool:zz"]); + } + /// A catalog row adds words in the UI language to a group, and a word that is not a single word /// or that is a word of another group is left out. #[test] @@ -1694,8 +1768,8 @@ mod tests { let started = std::time::Instant::now(); let c = catalog(Lang::EN, false); let built = started.elapsed(); - let started = std::time::Instant::now(); let params = super::super::params_texts(&c.list); + let started = std::time::Instant::now(); let index = Index::build(&c.list, &[], ¶ms, |_| None); println!("catalog {built:?}, index alone {:?}, {} results, {} bytes", started.elapsed(), c.list.len(), index.bytes()); let started = std::time::Instant::now();