Skip to main content

Module orderless

Module orderless 

Source
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:

WrittenMeans
foo barboth foo and bar must match, either order
!foocandidates containing foo are excluded
foo\ barone component containing a literal space
\!fooone 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§

OrderlessComponent
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 target against an orderless query.
parse_orderless_query
Split query into components on unescaped whitespace, resolving \<char> escapes and the leading-! negation marker.