summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorAugust Masquelier <31262046+levouh@users.noreply.github.com>2021-12-27 01:39:02 -0700
committerGitHub <noreply@github.com>2021-12-27 09:39:02 +0100
commit1849a8d701c24cb041848158dbf81591a182d87e (patch)
tree5ea2667715ae6337d62dd54943c7ddeeea1e3aa5 /lua
parent9aaaa0c5f3eb665b51bbcafda084de4b0952fef0 (diff)
fix(sorters): Ensure 'cb_filter' defined when creating new index-bias sorter (#1624)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/sorters.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/lua/telescope/sorters.lua b/lua/telescope/sorters.lua
index 4ad101e..167a67b 100644
--- a/lua/telescope/sorters.lua
+++ b/lua/telescope/sorters.lua
@@ -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