fix: Shortcircuit on nil entries and do not allow string entries
This commit is contained in:
@@ -43,8 +43,8 @@ function Sorter:new(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Sorter:score(prompt, entry)
|
function Sorter:score(prompt, entry)
|
||||||
-- TODO: Decide if we actually want to check the type every time.
|
if not entry or not entry.ordinal then return -1 end
|
||||||
return self:scoring_function(prompt or "", type(entry) == "string" and entry or entry.ordinal, entry)
|
return self:scoring_function(prompt or "", entry.ordinal, entry)
|
||||||
end
|
end
|
||||||
|
|
||||||
function sorters.new(...)
|
function sorters.new(...)
|
||||||
@@ -114,7 +114,7 @@ sorters.get_fuzzy_file = function(opts)
|
|||||||
scoring_function = function(_, prompt, line)
|
scoring_function = function(_, prompt, line)
|
||||||
local N = #prompt
|
local N = #prompt
|
||||||
|
|
||||||
if prompt == 0 or N < ngram_len then
|
if N == 0 or N < ngram_len then
|
||||||
-- TODO: If the character is in the line,
|
-- TODO: If the character is in the line,
|
||||||
-- then it should get a point or somethin.
|
-- then it should get a point or somethin.
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user