fix(sorters): Ensure 'cb_filter' defined when creating new index-bias sorter (#1624)
This commit is contained in:
committed by
GitHub
parent
9aaaa0c5f3
commit
1849a8d701
@@ -138,14 +138,14 @@ function Sorter:score(prompt, entry, cb_add, cb_filter)
|
||||
if self.tags then
|
||||
self.tags:insert(entry)
|
||||
end
|
||||
filter_score, prompt = self:filter_function(prompt, entry)
|
||||
filter_score, prompt = self:filter_function(prompt, entry, cb_add, cb_filter)
|
||||
end
|
||||
|
||||
if filter_score == FILTERED then
|
||||
return cb_filter(entry)
|
||||
end
|
||||
|
||||
local score = self:scoring_function(prompt or "", ordinal, entry)
|
||||
local score = self:scoring_function(prompt or "", ordinal, entry, cb_add, cb_filter)
|
||||
if score == FILTERED then
|
||||
self:_mark_discarded(prompt, ordinal)
|
||||
return cb_filter(entry)
|
||||
@@ -417,14 +417,14 @@ sorters.fuzzy_with_index_bias = function(opts)
|
||||
local fuzzy_sorter = sorters.get_generic_fuzzy_sorter(opts)
|
||||
|
||||
return Sorter:new {
|
||||
scoring_function = function(_, prompt, _, entry)
|
||||
local base_score = fuzzy_sorter:score(prompt, entry)
|
||||
scoring_function = function(_, prompt, line, entry, cb_add, cb_filter)
|
||||
local base_score = fuzzy_sorter:scoring_function(prompt, line, cb_add, cb_filter)
|
||||
|
||||
if base_score == -1 then
|
||||
return -1
|
||||
if base_score == FILTERED then
|
||||
return FILTERED
|
||||
end
|
||||
|
||||
if base_score == 0 then
|
||||
if not base_score or base_score == 0 then
|
||||
return entry.index
|
||||
else
|
||||
return math.min(math.pow(entry.index, 0.25), 2) * base_score
|
||||
|
||||
Reference in New Issue
Block a user