XMonad.Prompt.FuzzyMatch: handle case when input is not a subsequence of every completion

This commit is contained in:
Nick Hu 2020-10-14 17:10:49 +01:00
parent a69794892b
commit 1a085bec43
No known key found for this signature in database
GPG Key ID: 9E35DDA3DF631330
2 changed files with 7 additions and 1 deletions

View File

@ -111,6 +111,11 @@
Added `directoryMultipleModes'`, like `directoryMultipleModes` with an additional Added `directoryMultipleModes'`, like `directoryMultipleModes` with an additional
`ComplCaseSensitivity` argument. `ComplCaseSensitivity` argument.
* `XMonad.Prompt.FuzzyMatch`
`fuzzySort` will now accept cases where the input is not a subsequence of
every completion.
* `XMonad.Prompt.Shell` * `XMonad.Prompt.Shell`
Added `getShellCompl'`, like `getShellCompl` with an additional `ComplCaseSensitivity` Added `getShellCompl'`, like `getShellCompl` with an additional `ComplCaseSensitivity`

View File

@ -80,7 +80,8 @@ fuzzySort :: String -> [String] -> [String]
fuzzySort q = map snd . sort . map (rankMatch q) fuzzySort q = map snd . sort . map (rankMatch q)
rankMatch :: String -> String -> ((Int, Int), String) rankMatch :: String -> String -> ((Int, Int), String)
rankMatch q s = (minimum $ rankMatches q s, s) rankMatch q s = (if null matches then (maxBound, maxBound) else minimum matches, s)
where matches = rankMatches q s
rankMatches :: String -> String -> [(Int, Int)] rankMatches :: String -> String -> [(Int, Int)]
rankMatches [] _ = [(0, 0)] rankMatches [] _ = [(0, 0)]