feat: new fuzzy sorter

This commit is contained in:
TJ DeVries
2020-09-01 22:00:55 -04:00
parent 4ac50c68ca
commit c11a661362
6 changed files with 212 additions and 46 deletions

View File

@@ -237,13 +237,25 @@ describe('Sorters', function()
it('sort matches well', function()
local sorter = require('telescope.sorters').get_fuzzy_file()
local exact_match = sorter:score('hello', 'hello')
local exact_match = sorter:score('abcdef', 'abcdef')
local no_match = sorter:score('abcdef', 'ghijkl')
local ok_match = sorter:score('abcdef', 'ab')
assert(exact_match < no_match)
assert(exact_match < ok_match)
assert(ok_match < no_match)
assert(
exact_match < no_match,
string.format("Exact match better than no match: %s %s", exact_match, no_match)
)
assert(exact_match < ok_match, "Exact match better than OK match")
assert(ok_match < no_match, "OK match better than no match")
end)
it('sorts matches after last os sep better', function()
local sorter = require('telescope.sorters').get_fuzzy_file()
local exact_match = sorter:score('aaa/bbb', 'aaa')
local ok_match = sorter:score('bbb/aaa', 'aaa')
assert(exact_match < ok_match, "Exact match better than OK match")
end)
-- it('sorts multiple finds better', function()