WIP: Actually get the UI to work and add some tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
local log = require('telescope.log')
|
||||
local util = require('telescope.utils')
|
||||
|
||||
local sorters = {}
|
||||
@@ -12,7 +13,7 @@ Sorter.__index = Sorter
|
||||
---
|
||||
--- Lower number is better (because it's like a closer match)
|
||||
--- But, any number below 0 means you want that line filtered out.
|
||||
--- @param scoring_function function Function that has the interface:
|
||||
--- @field scoring_function function Function that has the interface:
|
||||
-- (sorter, prompt, line): number
|
||||
function Sorter:new(opts)
|
||||
opts = opts or {}
|
||||
@@ -59,4 +60,14 @@ sorters.get_ngram_sorter = function()
|
||||
}
|
||||
end
|
||||
|
||||
sorters.get_levenshtein_sorter = function()
|
||||
return Sorter:new {
|
||||
scoring_function = function(_, prompt, line)
|
||||
local result = require('telescope.algos.string_distance')(prompt, line)
|
||||
log.info("Sorting result for", prompt, line, " = ", result)
|
||||
return result
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
return sorters
|
||||
|
||||
Reference in New Issue
Block a user