Expand description
Orderless matching — a query is a set of independent components, not one string.
crate::fuzzy_match treats the whole query as a single token, so
"pic ref" only matches a candidate that literally contains
"pic ref". That is the limit users hit on a file picker, where the
two memorable fragments of a path are usually in the wrong order
(refilter lives under lattice-picker, so the natural query is
“picker” then “refilter”, but “ref pic” should work just as well).
Orderless splits the query on unescaped whitespace and requires
every component to match, in any order. Each component runs
the full 5-tier crate::fuzzy_match ladder, so the tier scores keep
prefix hits ranked above subsequence hits — prefix preference is
expressed in the ranking, not as a filter. That is the deliberate
divergence from emacs’ orderless-prefixes style, which drops
non-prefix matches outright: the symptom this exists to fix is “too
few matches”, and a stricter style would narrow the result set
further.
Syntax, in full:
| Written | Means |
|---|---|
foo bar | both foo and bar must match, either order |
!foo | candidates containing foo are excluded |
foo\ bar | one component containing a literal space |
\!foo | one component whose first character is a literal ! |
Scoring: the candidate’s score is the mean of its positive
components’ tier scores, plus ORDER_BONUS when those components
happen to match left-to-right. The mean (rather than the sum) keeps
the result inside the same 0..1000 band single-token matching already
produces, so a two-word query does not outrank a one-word query
purely by having more components — the picker’s MRU bonus stays
calibrated against the same scale.
A single positive component with no negations delegates verbatim to
crate::fuzzy_match, so the overwhelmingly common case is
bit-for-bit identical to the pre-orderless behaviour (same score,
same ranges, no order bonus).
Structs§
- Orderless
Component - One whitespace-separated piece of an orderless query.
Constants§
- ORDER_
BONUS - Added to a multi-component match whose components land in the order the user typed them. Set below the 200-point gap between adjacent match tiers so it acts as a within-tier tie-breaker and can never promote a subsequence match above a substring one.
Functions§
- orderless_
match - Match
targetagainst an orderlessquery. - parse_
orderless_ query - Split
queryinto components on unescaped whitespace, resolving\<char>escapes and the leading-!negation marker.