mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 08:53:33 +00:00
Command Palette: a plural or verb form finds the command
A query word in an English plural or verb form now meets the base word
of a result's English name or menu path: "rounded corners" lists Round
Corners… first, "scaling" finds Scale…, "rasterizes" finds Rasterize…
and "added anchor points" finds Add Anchor Points.
The index stores up to two stem forms per English word, and a query
word's stem forms are looked up exactly:
- 's is dropped, and sses becomes ss.
- es after s, x, z, ch or sh is dropped, and the word with only its s
dropped is a second form.
- A final s is dropped in words of more than 3 letters, except after
ss, us or is.
- ies becomes y or ie in words of more than 5 letters.
- ing (more than 5 letters) and ed (more than 4) are dropped. A doubled
b, d, g, m, n, p, r or t left before them gives the single and the
doubled letter, the single one only when at least 3 letters are left;
otherwise the rest with an e added is the second form.
- series and species are left as they are.
A result whose name holds the base word of a query word ranks below one
that holds the query word whole and above one where the query word only
starts a word of the name, so "scale" now lists a name with Scaling
above one with Scalers. A partly typed word that is not itself a word
of any result ("scal") does not meet a stem form. The grades of the
other matches keep their order and their sums, so results matched
without a stem keep their order. Names shown in other languages and ids
are not stemmed, and the words as written stay in the index, so every
result found before is still found.
This commit is contained in:
@@ -1761,10 +1761,12 @@ mod tests {
|
||||
assert_eq!(panels.len(), crate::state::all_panels().count());
|
||||
// Many results hold "layers" in their menu path; the panel, named Layers, is shown first, and "color guide" shows the Color Guide panel first too.
|
||||
for (query, want) in [("layers", "panel:layers"), ("color guide", "panel:colorGuide"), ("Layers ", "panel:layers")] {
|
||||
let all = entries.iter().filter(|e| query.to_lowercase().split_whitespace().all(|w| e.haystack.contains(w))).count();
|
||||
let all: Vec<&str> =
|
||||
entries.iter().filter(|e| query.to_lowercase().split_whitespace().all(|w| e.haystack.contains(w))).map(|e| e.id.as_str()).collect();
|
||||
let shown: Vec<&str> = matching(&entries, &query.to_lowercase()).into_iter().map(|e| e.id.as_str()).collect();
|
||||
assert_eq!(shown.first(), Some(&want), "{query}: {shown:?}");
|
||||
assert_eq!(shown.len(), all, "{query}");
|
||||
// English plural and verb forms can find more results than the text alone.
|
||||
assert!(all.iter().all(|id| shown.contains(id)), "{query}");
|
||||
}
|
||||
let layers = entries.iter().find(|e| e.id == "panel:layers").unwrap();
|
||||
assert_eq!(layers.shown, "Window › Show Panel › Layers");
|
||||
|
||||
@@ -10,19 +10,26 @@ use crate::menus;
|
||||
/// and the exact tiers read the whole query.
|
||||
const INDEX_CHARS: usize = 200;
|
||||
|
||||
/// The field of a result a word comes from, best first.
|
||||
/// The field of a result a word comes from, best first, and the fields of the English stem forms
|
||||
/// ([`stems`]) of the words of the label and the menu path.
|
||||
const LABEL: u8 = 0;
|
||||
const PATH: u8 = 1;
|
||||
const ID: u8 = 2;
|
||||
const LABEL_STEMMED: u8 = 3;
|
||||
const PATH_STEMMED: u8 = 4;
|
||||
|
||||
/// A word's grade in a result, best first: a whole word of the label, a word of the label it
|
||||
/// starts, a word of the menu path it is or starts, a word of the id it is or starts, or text
|
||||
/// inside a word of any field ([`super::matching`]'s substring rule).
|
||||
const LABEL_WORD: u8 = 1;
|
||||
const LABEL_PREFIX: u8 = 2;
|
||||
const PATH_WORD: u8 = 3;
|
||||
const ID_WORD: u8 = 4;
|
||||
const SUBSTRING: u8 = 5;
|
||||
/// shares an English stem form with ("outlines" and Outline), a word of the label it starts, a
|
||||
/// word of the menu path it is, shares a stem form with or starts, a word of the id it is or
|
||||
/// starts, or text inside a word of any field ([`super::matching`]'s substring rule). The grades
|
||||
/// without a stem are twice the values they had before stems were added, so results matched
|
||||
/// without a stem keep their order by the sum of the grades.
|
||||
const LABEL_WORD: u8 = 2;
|
||||
const LABEL_STEM: u8 = 3;
|
||||
const LABEL_PREFIX: u8 = 4;
|
||||
const PATH_WORD: u8 = 6;
|
||||
const ID_WORD: u8 = 8;
|
||||
const SUBSTRING: u8 = 10;
|
||||
const NONE: u8 = u8::MAX;
|
||||
|
||||
/// How a whole query matches a result, best first: it is the result's id, it is a label, a label
|
||||
@@ -34,7 +41,7 @@ const INITIALS: u8 = 3;
|
||||
const NO_PHRASE: u8 = 4;
|
||||
|
||||
/// One result in the list of a term: the result's place in the catalog and the field the term is
|
||||
/// a word of.
|
||||
/// a word or a word's stem form of.
|
||||
#[derive(Clone, Copy)]
|
||||
struct Posting {
|
||||
entry: u16,
|
||||
@@ -73,6 +80,70 @@ fn initials_of(label: &str) -> String {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The English stem forms of the lowercased `word`, at most two, and none for a word that is not
|
||||
/// plain English letters. `'s` is dropped; `sses` becomes `ss`; `es` after `s`, `x`, `z`, `ch` or
|
||||
/// `sh` is dropped, and with only its `s` dropped the word is a second form (`boxes`, `box` and
|
||||
/// `boxe`; `rasterizes`, `rasteriz` and `rasterize`); in a word of more than 5 letters, `ies`
|
||||
/// becomes `y` or `ie` (`copies`, `copy` and `copie`; `movies`, `movy` and `movie`); `ing` (more
|
||||
/// than 5 letters) and `ed` (more than 4) are dropped, and when a doubled `b`, `d`, `g`, `m`, `n`,
|
||||
/// `p`, `r` or `t` is left before them, the rest with that letter made single and the rest as it
|
||||
/// is are the forms (`cutting`, `cut` and `cutt`), the single one only when it keeps at least 3
|
||||
/// letters (`added`, `add` alone); otherwise the rest and the rest followed by `e` are the forms
|
||||
/// (`scaling`, `scal` and `scale`); a final `s` is dropped from a word of more than 3 letters that
|
||||
/// does not end in `ss`, `us` or `is`. `series` and `species` have none.
|
||||
fn stems(word: &str) -> Vec<String> {
|
||||
let one = |rest: &str| if rest.is_empty() { vec![] } else { vec![rest.to_string()] };
|
||||
if !word.bytes().all(|b| b.is_ascii_lowercase() || b == b'\'') || matches!(word, "series" | "species") {
|
||||
return vec![];
|
||||
}
|
||||
let n = word.len();
|
||||
if let Some(rest) = word.strip_suffix("'s") {
|
||||
return one(rest);
|
||||
}
|
||||
if let Some(rest) = word.strip_suffix("sses") {
|
||||
return vec![format!("{rest}ss")];
|
||||
}
|
||||
if let Some(rest) = word.strip_suffix("es")
|
||||
&& ["s", "x", "z", "ch", "sh"].iter().any(|end| rest.ends_with(end))
|
||||
{
|
||||
return vec![rest.to_string(), format!("{rest}e")];
|
||||
}
|
||||
if n > 5
|
||||
&& let Some(rest) = word.strip_suffix("ies")
|
||||
{
|
||||
return vec![format!("{rest}y"), format!("{rest}ie")];
|
||||
}
|
||||
let verb = if n > 5 { word.strip_suffix("ing") } else { None }.or_else(|| if n > 4 { word.strip_suffix("ed") } else { None });
|
||||
if let Some(rest) = verb {
|
||||
if let [.., a, b] = rest.as_bytes()
|
||||
&& a == b
|
||||
&& b"bdgmnprt".contains(a)
|
||||
{
|
||||
let single = rest.get(..rest.len() - 1).unwrap_or_default();
|
||||
if single.len() < 3 {
|
||||
return vec![rest.to_string()];
|
||||
}
|
||||
return vec![single.to_string(), rest.to_string()];
|
||||
}
|
||||
return vec![rest.to_string(), format!("{rest}e")];
|
||||
}
|
||||
if n > 3 && word.ends_with('s') && !["ss", "us", "is"].iter().any(|end| word.ends_with(end)) {
|
||||
return one(word.get(..n - 1).unwrap_or_default());
|
||||
}
|
||||
vec![]
|
||||
}
|
||||
|
||||
/// Adds each word of `text` to `found` for result `entry` in `field`, and with `stemmed`, each
|
||||
/// word's English stem forms in that field.
|
||||
fn add_words(found: &mut Vec<(String, u16, u8)>, text: &str, entry: u16, field: u8, stemmed: Option<u8>) {
|
||||
for w in words(text) {
|
||||
found.push((w.to_string(), entry, field));
|
||||
if let Some(stemmed) = stemmed {
|
||||
found.extend(stems(w).into_iter().map(|s| (s, entry, stemmed)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A name's last `›`-separated part (the label) and the parts before it (the menu path).
|
||||
fn split_name(name: &str) -> (&str, &str) {
|
||||
match name.rsplit_once(" › ") {
|
||||
@@ -99,9 +170,10 @@ fn ids(e: &Entry) -> impl Iterator<Item = &str> {
|
||||
|
||||
impl Index {
|
||||
/// The index of `entries`, whose menu homes and menu items read `homes` in the UI language. The
|
||||
/// words of a result's menu home and of its menu item's label count as menu path words. A
|
||||
/// catalog with more results than a posting can name gets an empty index, and queries match by
|
||||
/// the substring rule alone.
|
||||
/// words of a result's menu home and of its menu item's label count as menu path words. The
|
||||
/// words of the English names, menu home and menu item label also add their English stem forms
|
||||
/// ([`stems`]); words in the UI language do not. A catalog with more results than a posting can
|
||||
/// name gets an empty index, and queries match by the substring rule alone.
|
||||
pub(crate) fn build(entries: &[Entry], homes: &[Option<String>]) -> Index {
|
||||
if entries.len() > usize::from(u16::MAX) {
|
||||
return Index::default();
|
||||
@@ -114,10 +186,13 @@ impl Index {
|
||||
let id = ids(e).next().unwrap_or_default();
|
||||
let start = initials_text.len();
|
||||
let mut seen_initials: Vec<String> = vec![];
|
||||
for name in names(e) {
|
||||
// The first two names are English, so their words also give stem forms; the shown name
|
||||
// may be in another language, and its words are indexed as they are.
|
||||
for (n, name) in names(e).enumerate() {
|
||||
let english = n < 2;
|
||||
let (label, path) = split_name(without_id(name, id));
|
||||
found.extend(words(label).map(|w| (w.to_string(), entry, LABEL)));
|
||||
found.extend(words(path).map(|w| (w.to_string(), entry, PATH)));
|
||||
add_words(&mut found, label, entry, LABEL, english.then_some(LABEL_STEMMED));
|
||||
add_words(&mut found, path, entry, PATH, english.then_some(PATH_STEMMED));
|
||||
let ini = initials_of(label);
|
||||
if ini.chars().count() >= 2 && !seen_initials.contains(&ini) {
|
||||
if !seen_initials.is_empty() {
|
||||
@@ -127,8 +202,11 @@ impl Index {
|
||||
seen_initials.push(ini);
|
||||
}
|
||||
}
|
||||
for home in [e.home.as_deref(), Some(e.menu_item), homes.get(i).and_then(Option::as_deref)].into_iter().flatten() {
|
||||
found.extend(words(&home.to_lowercase()).map(|w| (w.to_string(), entry, PATH)));
|
||||
for home in [e.home.as_deref(), Some(e.menu_item)].into_iter().flatten() {
|
||||
add_words(&mut found, &home.to_lowercase(), entry, PATH, Some(PATH_STEMMED));
|
||||
}
|
||||
if let Some(home) = homes.get(i).and_then(Option::as_deref) {
|
||||
add_words(&mut found, &home.to_lowercase(), entry, PATH, None);
|
||||
}
|
||||
for id in ids(e) {
|
||||
found.extend(words(id).map(|w| (w.to_string(), entry, ID)));
|
||||
@@ -183,10 +261,33 @@ impl Index {
|
||||
self.term_text.get(offset..offset + len as usize).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The best grade (1 to 4) `word` gets in each result, [`NONE`] where it is no word and starts
|
||||
/// no word of the result. The words it starts are found by a binary search of the sorted words.
|
||||
/// The postings of the word at place `t` in `terms`.
|
||||
fn postings_of(&self, t: usize) -> &[Posting] {
|
||||
let Some(&(begin, len)) = self.spans.get(t) else { return &[] };
|
||||
let (begin, len) = (begin as usize, len as usize);
|
||||
self.postings.get(begin..begin + len).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The place of the word `text` in `terms`, found by a binary search.
|
||||
fn find(&self, text: &str) -> Option<usize> {
|
||||
self.terms.binary_search_by(|t| self.text(t).cmp(text)).ok()
|
||||
}
|
||||
|
||||
/// The best grade ([`LABEL_WORD`] to [`ID_WORD`]) `word` gets in each result, [`NONE`] where it
|
||||
/// is no word, shares no English stem form with a word of the label or menu path, and starts no
|
||||
/// word of the result. The words it starts are found by a binary search of the sorted words; a
|
||||
/// stem form matches only a word or stem form equal to it.
|
||||
fn grades(&self, word: &str, n: usize) -> Vec<u8> {
|
||||
let mut out = vec![NONE; n];
|
||||
let mut mark = |postings: &[Posting], grade: &dyn Fn(u8) -> Option<u8>| {
|
||||
for p in postings {
|
||||
if let Some(grade) = grade(p.field)
|
||||
&& let Some(g) = out.get_mut(usize::from(p.entry))
|
||||
{
|
||||
*g = (*g).min(grade);
|
||||
}
|
||||
}
|
||||
};
|
||||
let start = self.terms.partition_point(|t| self.text(t) < word);
|
||||
for (t, at) in self.terms.iter().enumerate().skip(start) {
|
||||
let term = self.text(at);
|
||||
@@ -194,19 +295,37 @@ impl Index {
|
||||
break;
|
||||
}
|
||||
let whole = term == word;
|
||||
let Some(&(begin, len)) = self.spans.get(t) else { continue };
|
||||
let (begin, len) = (begin as usize, len as usize);
|
||||
for p in self.postings.get(begin..begin + len).unwrap_or_default() {
|
||||
let grade = match p.field {
|
||||
LABEL if whole => LABEL_WORD,
|
||||
LABEL => LABEL_PREFIX,
|
||||
PATH => PATH_WORD,
|
||||
_ => ID_WORD,
|
||||
};
|
||||
if let Some(g) = out.get_mut(usize::from(p.entry)) {
|
||||
*g = (*g).min(grade);
|
||||
}
|
||||
}
|
||||
// A stem form is not a word of the result, so a query word that only starts it does
|
||||
// not match.
|
||||
mark(self.postings_of(t), &|field| match field {
|
||||
LABEL if whole => Some(LABEL_WORD),
|
||||
LABEL => Some(LABEL_PREFIX),
|
||||
PATH => Some(PATH_WORD),
|
||||
ID => Some(ID_WORD),
|
||||
_ => None,
|
||||
});
|
||||
}
|
||||
// The word meets a stem form of a word of the result ("scale" and Scaling) when it is itself
|
||||
// a word of some result, so a partly typed word ("scal") that only equals a stem form does
|
||||
// not lift Scaling above Scale.
|
||||
if let Some(t) = self.find(word)
|
||||
&& self.postings_of(t).iter().any(|p| matches!(p.field, LABEL | PATH | ID))
|
||||
{
|
||||
mark(self.postings_of(t), &|field| match field {
|
||||
LABEL_STEMMED => Some(LABEL_STEM),
|
||||
PATH_STEMMED => Some(PATH_WORD),
|
||||
_ => None,
|
||||
});
|
||||
}
|
||||
// A stem form of the word meets a word of the result or a stem form of one ("outlines"
|
||||
// and Outline, "rotated" and Rotating). Ids are not stemmed.
|
||||
for form in stems(word) {
|
||||
let Some(t) = self.find(&form) else { continue };
|
||||
mark(self.postings_of(t), &|field| match field {
|
||||
LABEL | LABEL_STEMMED => Some(LABEL_STEM),
|
||||
PATH | PATH_STEMMED => Some(PATH_WORD),
|
||||
_ => None,
|
||||
});
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -267,10 +386,11 @@ type RankKey = (u8, u8, u32, u8, usize);
|
||||
/// The results of `entries` that the lowercased `query` matches, best first, as places in
|
||||
/// `entries`. A result matches when every word of the query is text in one of its names or ids
|
||||
/// (the rule the palette always had, so nothing it found is lost), when every word of the query is
|
||||
/// or starts a word of its label, menu path or id, or when the query is the initials of a label
|
||||
/// ("ea" for Export As…). Results are ordered by how the whole query matches ([`phrase`]), then by
|
||||
/// the worst grade a word gets, the sum of the grades, the kind of result ([`kind`]), the label's
|
||||
/// length and the catalog order. An empty query lists every result in catalog order.
|
||||
/// or starts a word of its label, menu path or id or shares an English stem form with a word of its
|
||||
/// label or menu path ("rounded corners" for Round Corners…), or when the query is the initials of
|
||||
/// a label ("ea" for Export As…). Results are ordered by how the whole query matches ([`phrase`]),
|
||||
/// then by the worst grade a word gets, the sum of the grades, 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<u32> {
|
||||
let query = normalize(query);
|
||||
if query.is_empty() {
|
||||
@@ -412,8 +532,13 @@ mod tests {
|
||||
for (query, better, worse) in [
|
||||
// A whole word of the label, then a word of the label it starts.
|
||||
("cut zz", entry("Zz Cut", "a.one"), entry("Zz Cutter", "b.two")),
|
||||
// A whole word of the label, then a word of the label it shares a stem form with.
|
||||
("scale zz", entry("Zz Scale", "a.one"), entry("Zz Scaling", "b.two")),
|
||||
// A word of the label it shares a stem form with, then a word of the label it starts.
|
||||
// The id makes "scale" a word of the catalog.
|
||||
("scale zz", entry("Zz Scaling", "a.one"), entry("Zz Scalers", "scale.two")),
|
||||
// A word of the label it starts, then a word of the menu path.
|
||||
("fill zz", entry("Zz Filling", "a.one"), entry("Fill › Zz Other", "b.two")),
|
||||
("fill zz", entry("Zz Fillet", "a.one"), entry("Fill › Zz Other", "b.two")),
|
||||
// A word of the menu path, then a word of the id.
|
||||
("zap zz", entry("Zap › Zz One", "a.one"), entry("Zz Two", "zap.two")),
|
||||
// A word of the id, then text inside a word.
|
||||
@@ -426,6 +551,26 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A partly typed word that equals only a stem form ("scal" of Scaling, "spac" of Spacing) is a
|
||||
/// word the query starts in both results, so the shorter label stays first.
|
||||
#[test]
|
||||
fn a_partly_typed_word_does_not_lift_a_verb_form() {
|
||||
for (query, base, form) in [("scal zz", "Zz Scale", "Zz Scaling"), ("spac zz", "Zz Space", "Zz Spacing"), ("ad zz", "Zz Add", "Zz Added")] {
|
||||
let c = synthetic(vec![entry(form, "a.one"), entry(base, "b.two")]);
|
||||
assert_eq!(ranked(&c, query), ["b.two", "a.one"], "{query}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Results that no stem form matches keep the order they had before stems were added: two
|
||||
/// results whose grades summed the same still tie on the sum, and the shorter label comes
|
||||
/// first.
|
||||
#[test]
|
||||
fn results_matched_without_a_stem_keep_their_order() {
|
||||
// Two label prefixes and a menu path word, against a label word and two menu path words.
|
||||
let c = synthetic(vec![entry("Bet › Gam › Alp Zzzzzzzzzz", "b.two"), entry("Gam › Alpx Betx", "a.one")]);
|
||||
assert_eq!(ranked(&c, "alp bet gam"), ["a.one", "b.two"]);
|
||||
}
|
||||
|
||||
/// For each pair of adjacent whole-query tiers, a result in the better tier ranks above one in
|
||||
/// the worse.
|
||||
#[test]
|
||||
@@ -476,6 +621,77 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Do `a` and `b` share a form, each taken as it is or as one of its stem forms?
|
||||
fn meet(a: &str, b: &str) -> bool {
|
||||
let forms = |w: &str| std::iter::once(w.to_string()).chain(stems(w)).collect::<Vec<_>>();
|
||||
let b = forms(b);
|
||||
forms(a).iter().any(|f| b.contains(f))
|
||||
}
|
||||
|
||||
/// English plurals and verb forms meet their base word, and words that only look alike do not.
|
||||
#[test]
|
||||
fn plurals_and_verb_forms_meet_their_base_word() {
|
||||
for (a, b) in [
|
||||
("outlines", "outline"),
|
||||
("rounded", "round"),
|
||||
("paths", "path"),
|
||||
("cutting", "cut"),
|
||||
("scaling", "scale"),
|
||||
("rotated", "rotate"),
|
||||
("spacing", "space"),
|
||||
("tracing", "trace"),
|
||||
("curved", "curve"),
|
||||
("filled", "fill"),
|
||||
("missing", "missing"),
|
||||
("boxes", "box"),
|
||||
("brushes", "brush"),
|
||||
("glasses", "glass"),
|
||||
("copies", "copy"),
|
||||
("movies", "movie"),
|
||||
("artist's", "artist"),
|
||||
("rotated", "rotating"),
|
||||
("added", "add"),
|
||||
("rasterizes", "rasterize"),
|
||||
("sizes", "size"),
|
||||
] {
|
||||
assert!(meet(a, b), "{a} meets {b}");
|
||||
}
|
||||
for (a, b) in [("series", "sery"), ("missing", "mis"), ("press", "pres"), ("bus", "bu"), ("axis", "axi"), ("cutting", "cu"), ("added", "ad")]
|
||||
{
|
||||
assert!(!meet(a, b), "{a} does not meet {b}");
|
||||
}
|
||||
for w in ["outlines", "scaling", "cutting", "copies", "s", "'s", "ed", "ing", "übers", "群組", "series"] {
|
||||
assert!(stems(w).len() <= 2, "{w}");
|
||||
assert!(stems(w).iter().all(|s| !s.is_empty() && s != w), "{w}: {:?}", stems(w));
|
||||
}
|
||||
assert!(stems("übers").is_empty() && stems("series").is_empty() && stems("species").is_empty());
|
||||
}
|
||||
|
||||
/// A query word in a plural or verb form finds a result whose label or menu path holds the base
|
||||
/// word, below one that holds the word itself, and the words of a name shown in another language
|
||||
/// are not stemmed.
|
||||
#[test]
|
||||
fn a_plural_or_verb_form_finds_the_result() {
|
||||
let c = synthetic(vec![entry("Zz Rotate", "a.one"), entry("Spacing › Zz Other", "b.two"), entry("Zz Rotated", "c.three")]);
|
||||
assert_eq!(ranked(&c, "rotating"), ["a.one", "c.three"]);
|
||||
assert_eq!(ranked(&c, "rotated"), ["c.three", "a.one"]);
|
||||
assert_eq!(ranked(&c, "spaces other"), ["b.two"], "through the menu path");
|
||||
let shown = Entry { shown: "Zz Trees".into(), haystack: "zz one\nzz one\nzz trees\na.one".into(), ..entry("Zz One", "a.one") };
|
||||
let c = synthetic(vec![shown, entry("Zz Trees", "b.two")]);
|
||||
assert_eq!(ranked(&c, "treed zz"), ["b.two"], "only the English name is stemmed");
|
||||
let en = catalog(Lang::EN, false);
|
||||
assert!(place(&en, "outlines", "type.createOutlines").is_some_and(|p| p < 3));
|
||||
assert_eq!(ranked(&en, "rounded corners").first().map(String::as_str), Some("effect:stylize.roundCorners"));
|
||||
for (q, id) in [
|
||||
("scaling", "object.scale"),
|
||||
("rotated", "object.rotate"),
|
||||
("rasterizes", "object.rasterize"),
|
||||
("added anchor points", "object.path.addAnchorPoints"),
|
||||
] {
|
||||
assert!(place(&en, q, id).is_some(), "{q} finds {id}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The application menu of the native Mac menu bar holds the items [`menu_homes`] puts there,
|
||||
/// under the same submenus.
|
||||
#[test]
|
||||
|
||||
@@ -1305,6 +1305,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
The Command Palette shows each result as a 20-point row, with no gap between rows, and shows 12 rows at a time in a list that scrolls; a short window shows fewer. A name too long for its row ends with "…". The list holds up to 50 results, and the line under it says how many matched ("14 results", "50 of 120 results. Keep typing to narrow them." or "No commands match"). Up and Down move the highlight and wrap at the ends, Page Up and Page Down move it by the rows shown and stop at the ends, and the highlighted row scrolls into view; after a scroll with the wheel, the highlight moves to the nearest row in view. A click anywhere on a row runs it. Screen readers stay on the search field, whose description names the highlighted result and its place among every match ("2 of 14: …", or "2 of 120: …" when the list holds 50); the rows are list items, the highlighted one selected, and the keyboard focus goes back to where it was when the palette closes, unless a pick opened a dialog (`palette` tests `results_are_compact_rows_that_touch`, `the_footer_counts_the_results`, `with_no_match_enter_runs_nothing`, `the_sixteenth_result_is_reached_by_keyboard_and_runs`, `page_keys_move_by_a_page_without_wrapping`, `a_wheel_scroll_keeps_the_highlight_in_view`, `the_row_under_the_pointer_is_the_one_highlighted`, `a_long_name_ends_with_an_ellipsis`, `the_popup_stays_inside_a_short_window`, `a_click_anywhere_on_a_row_runs_it`, `screen_readers_hear_the_highlighted_result_and_the_count`, `closing_gives_the_focus_back`).
|
||||
A press of any pointer button outside the Command Palette closes it: a click, a right-click or the start of a drag. While the palette is open, the canvas, the toolbars, the docked panels and the app bar under it do not respond to the pointer, so the press that closes the palette does not press a tool button or another control there. A window drawn above them, such as a progress window, still gets its click, and that click also closes the palette (`palette` tests `a_click_on_the_canvas_closes_the_palette`, `a_click_on_another_control_closes_the_palette_without_pressing_it`, `a_right_click_or_a_drag_outside_closes_the_palette`, `a_click_on_a_window_above_closes_the_palette_and_reaches_it`, `the_click_that_opens_the_palette_does_not_close_it`).
|
||||
The Command Palette ranks its results by how well they match. A query that is a result's id lists that result first (`view.goto1` lists Saved View 1 above Saved View 10); then come results whose name is the query, results whose name without its menu path starts with it, and results whose initials it is ("ea" finds Export As…). Within each of those, a result where every word of the query is a whole word of its name ranks above one where a word only starts a word of the name, then one where it is a word of the menu that holds it, then of its id, then text inside a word, so a query that is a menu's title ("object") lists results named with that word above the items of that menu. A tool ranks above a menu command, panel, effect or filter plug-in that matches as well, so "rect" lists the Rectangle Tool above Effect › Convert to Shape › Rectangle…, and of two results of the same kind the shorter name comes first. Words of the menu bar item that runs a result also find it, the item's own label included ("exit" finds Quit VectorCraft, which File › Exit runs); with the native macOS menu bar, the items that bar moves into its application menu are found under it (Preferences… under Settings). Every result the earlier search found is still found, and the highlight stays on its result when a plug-in is installed, a shortcut changes or the language changes while the palette is open (`palette::search` tests `a_better_word_grade_ranks_first`, `a_better_whole_query_tier_ranks_first`, `kind_and_length_never_lift_a_worse_grade`, `a_menu_title_does_not_lift_its_items`, `common_queries_list_the_command_near_the_top`, `every_result_is_found_first_by_its_name_and_its_id`, `every_result_found_before_is_still_found_and_shown`, `results_know_their_place_in_the_menu_bar`, `native_homes_follow_the_native_application_menu`; `palette` test `the_highlight_stays_on_its_result_when_the_results_change`).
|
||||
A Command Palette query word in an English plural or verb form finds a result whose English name or menu path holds the base word: "rounded corners" lists Effect › Stylize › Round Corners… first, and "scaling" finds Object › Transform › Scale…. The search drops `'s`; `es` after `s`, `x`, `z`, `ch` or `sh` (also trying the word with only its `s` dropped, so "rasterizes" finds Rasterize…); a final `s` in words of more than 3 letters, except after `ss`, `us` or `is`; `ing` in words of more than 5 letters and `ed` in words of more than 4. After `ing` or `ed`, a doubled `b`, `d`, `g`, `m`, `n`, `p`, `r` or `t` is tried both single and doubled, the single letter only when at least 3 letters are left ("cutting" meets Cut, "added" meets Add); otherwise the word is also tried with an `e` ("scaling" meets Scale…). It turns `ies` into `y` or `ie` in words of more than 5 letters and `sses` into `ss`, and leaves `series` and `species` as they are. A result whose name holds the base word of a query word ranks below one that holds the query word whole and above one where the query word only starts a word of the name, so "scale" now lists a name with "Scaling" above one with "Scalers". A partly typed word that is not itself a word of any result ("scal") does not meet a base word. Names shown in other languages and ids are not changed this way, and every result found before is still found (`palette::search` tests `plurals_and_verb_forms_meet_their_base_word`, `a_plural_or_verb_form_finds_the_result`, `a_better_word_grade_ranks_first`, `a_partly_typed_word_does_not_lift_a_verb_form`, `results_matched_without_a_stem_keep_their_order`).
|
||||
`object.setProps` with `visible: false` or `locked: true` deselects every selected object that is then hidden or locked, the key object included, as the eye and lock columns do.
|
||||
Ctrl/Cmd+Alt-clicking an eye switches the other layers to Outline and the row's layer to Preview, or switches all layers back to Preview when the others are in Outline (`layer.outlineOthers`, `layer.previewAll`).
|
||||
Ctrl/Cmd+Alt-clicking New Layer adds a layer directly below the current layer, at its level (`layer.new {below: true}`), and Ctrl/Cmd+Alt-clicking New Sublayer adds a sublayer under the contents of the layer it goes into (`layer.newSublayer {bottom: true}`), each in one undo step. The reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists these clicks for placing a layer below the selected layer and a new sublayer at the bottom of the layer list.
|
||||
|
||||
Reference in New Issue
Block a user