Expand description
A port of fzf’s query language — src/pattern.go from fzf 0.74.3.
fzf’s default search mode is EXTENDED: a query is a space-separated list of
terms that must all match (AND), | between terms makes an OR set, and a
term can carry a sigil that changes how it matches:
fuzzy 'exact ^prefix suffix$ ^equal$ 'boundary'
!inverse !'inverse-fuzzy !^inverse-prefix !inverse-suffix$Everything here is a PORT, not an approximation — parseTerms, the term
type flips, extendedMatch’s OR/AND/inverse walk and the sortable /
cacheable flags all follow the Go source, so arb --fzf answers a query
the way fzf answers it. -x/--extended and +x/--no-extended select
the mode; extended is the default, as in fzf.
A Pattern is built ONCE per query and scored against every line. That is
deliberate: the pattern’s Vec<char> and case decision are per-QUERY work,
and doing them per line (as arb did before this module existed) cost more
than the match itself on a query that rejects most of the corpus.
Structs§
- Bounds
- Where a pattern matched a line, folded across every term set — fzf’s
buildResultinputs (result.go:32).min_begin/min_end/max_endare character indices; a term that located nothing (a satisfied!term) contributes an empty offset and is skipped. - Pattern
- A parsed query, ready to score any number of lines.
- Term
- One term of a query: the text to look for, how to look for it, and whether
finding it DISQUALIFIES the line (
!).
Enums§
- Criterion
- One ranking criterion — fzf’s
criterion(options.go:268).Scoreis always first; the rest are the--tiebreaklist, applied in order, with the item’s input index as the final, implicit tiebreak. - Term
Type - How one term matches — fzf’s
termType(pattern.go:22).
Functions§
- compare_
points - fzf’s
compareRanks(result_x86.go): the four slots read as one integer, most significant first, then the item’s input index breaks a full tie. - parse_
tiebreak - fzf’s
parseTiebreak(options.go:1349).indexadds no criterion — it IS the implicit final one — but it must come last, and no name may repeat.Nonefor a spec fzf would reject, which keeps the caller’s default. - points
- fzf’s
buildResultFromBounds(result.go:54): pack the criteria into fouru16slots, best-first, so ordering is one integer comparison per pair. - scan_
direction - fzf’s
core.go:215: the--tiebreakcriteria decide how the matchers scan. Returns(forward, with_pos). - scheme_
criteria - The criteria a
--schemeimplies when--tiebreakis not given — fzf’sparseScheme(options.go:1336).