blob: f009f616cada41a8f5b04c246ac669e9c38bd496 [file]
import Lean
open Lean Elab
def orderFuzzyMatches (names : Array Name) (pattern : String) : Array Name :=
names.filterMap (fun n => (n, ·) <$> Lean.FuzzyMatching.fuzzyMatchScoreWithThreshold? pattern n.toString) |>.qsort (·.2 ≥ ·.2) |>.map (·.1)
-- patterns matching at the end of a name should get a bonus
#eval orderFuzzyMatches #[`Array.extract, `Lean.extractMainModule] "extract"