Expand description
Fuzzy matching, for the pickers and the : completion list.
Subsequence matching on its own is not enough once a picker is ranking a thousand
workflows rather than eighty command ids. ord is a subsequence of nearly every string
in a list of Temporal ids, so without a score the useful hit is somewhere in the middle
of nine hundred equally-valid ones and the picker is worse than scrolling.
So this scores. The weights are not tuned to a benchmark, they encode three things people actually do when they type at a picker:
- They type the start of a word:
ocshould findorder-checkoutbefore it findsprOCess, and the first character they type is the one they aim hardest with. - They type runs, not scattered letters:
checreads as one piece, and a haystack that contains it contiguously beats one that spells it out across four words. - They type the beginning of the thing. Earlier matches beat later ones, and a shorter haystack beats a longer one holding the same match.
Case follows the same smartcase rule as /, for one less thing to remember. See
crate::search, which is the other kind of finding: that one walks the rows already
on screen, this one reorders a list by how well it matches.
Structs§
- Match
- A scored hit.
Functions§
- match_
score - Score
haystackagainstneedle, orNoneif it does not match at all. - matches
- Whether this haystack matches at all, without paying for the score.
- rank
- Rank
itemsby how well their text matchesneedle, best first.