Skip to main content

Module fuzzy

Module fuzzy 

Source
Expand description

Fuzzy matching scored as fzf scores it, so ranking matches the finder people already know (fzf, fzf-lua, Telescope’s fzf-native and snacks.picker, a port of fzf/src/algo/algo.go, all agree). The scoring constants are fzf’s:

  • a match right after / or _ beats one mid-word
  • consecutive characters beat scattered ones
  • a match in the file name beats one in a directory
  • the best alignment wins, not the first found (revdetail lands on revenue, not the re in warehouse)

Structs§

Match
A match: its score and the characters that made it, from the same alignment, so highlights show what was scored.

Functions§

best_match
The best fuzzy match of needle in haystack, or None: every start is tried and the highest alignment wins. Case-insensitive; an empty needle matches with score 0.
is_match
Whether needle matches at all, without scoring: a one-pass gate before best_match, since most candidates fail.
substring_rank
Where a needle sits in a name, for a list narrowed by substring: the whole name (0), its start (1), or inside it (2). None when the name does not contain it. Case-insensitive; an empty needle is inside every name.