From 1849a8d701c24cb041848158dbf81591a182d87e Mon Sep 17 00:00:00 2001 From: August Masquelier <31262046+levouh@users.noreply.github.com> Date: Mon, 27 Dec 2021 01:39:02 -0700 Subject: [PATCH] fix(sorters): Ensure 'cb_filter' defined when creating new index-bias sorter (#1624) --- lua/telescope/sorters.lua | 14 +++++++------- 1 file 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