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
|
if self.tags then
|
||||||
self.tags:insert(entry)
|
self.tags:insert(entry)
|
||||||
end
|
end
|
||||||
filter_score, prompt = self:filter_function(prompt, entry)
|
filter_score, prompt = self:filter_function(prompt, entry, cb_add, cb_filter)
|
||||||
end
|
end
|
||||||
|
|
||||||
if filter_score == FILTERED then
|
if filter_score == FILTERED then
|
||||||
return cb_filter(entry)
|
return cb_filter(entry)
|
||||||
end
|
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
|
if score == FILTERED then
|
||||||
self:_mark_discarded(prompt, ordinal)
|
self:_mark_discarded(prompt, ordinal)
|
||||||
return cb_filter(entry)
|
return cb_filter(entry)
|
||||||
@@ -417,14 +417,14 @@ sorters.fuzzy_with_index_bias = function(opts)
|
|||||||
local fuzzy_sorter = sorters.get_generic_fuzzy_sorter(opts)
|
local fuzzy_sorter = sorters.get_generic_fuzzy_sorter(opts)
|
||||||
|
|
||||||
return Sorter:new {
|
return Sorter:new {
|
||||||
scoring_function = function(_, prompt, _, entry)
|
scoring_function = function(_, prompt, line, entry, cb_add, cb_filter)
|
||||||
local base_score = fuzzy_sorter:score(prompt, entry)
|
local base_score = fuzzy_sorter:scoring_function(prompt, line, cb_add, cb_filter)
|
||||||
|
|
||||||
if base_score == -1 then
|
if base_score == FILTERED then
|
||||||
return -1
|
return FILTERED
|
||||||
end
|
end
|
||||||
|
|
||||||
if base_score == 0 then
|
if not base_score or base_score == 0 then
|
||||||
return entry.index
|
return entry.index
|
||||||
else
|
else
|
||||||
return math.min(math.pow(entry.index, 0.25), 2) * base_score
|
return math.min(math.pow(entry.index, 0.25), 2) * base_score
|
||||||
|
|||||||
Reference in New Issue
Block a user