Browse the docs

fuzzyMatch

The best match for a query in a list.

Details #

fuzzyMatch(query, list) ranks the list the way the command palette ranks its rows (a prefix beats the start of a word, beats text inside a word, beats letters in order) and returns the best as a record with item, index (counting from 0) and score, or nothing when no item matches. Case and accents are ignored. A query of several words needs every word to match.

Parameters #

Takes 2 arguments. {{ fuzzyMatch(text, b) }}

Examples #

fuzzyMatch("sett", ["Open Settings", "Settings", "Quit"]).item
→ Settings
fuzzyMatch(name, appNames).index
→ 1
Sample variableValue
appNames["Safari", "Terminal", "Mail"]
nameterm

Gotchas #

  • An empty query matches nothing.

  • Items that are not text are matched by their text.