From e46ef8ffec1637d17dc3f91ade54af3258d5284e Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Sat, 21 Aug 2021 20:53:09 +0200 Subject: [PATCH] fix: for default sorters so we dont sort data after ordinal len if #prompt == 0 (#1146) --- lua/telescope/sorters.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/telescope/sorters.lua b/lua/telescope/sorters.lua index c3c584c..4ad101e 100644 --- a/lua/telescope/sorters.lua +++ b/lua/telescope/sorters.lua @@ -244,7 +244,7 @@ sorters.get_fuzzy_file = function(opts) if N == 0 or N < ngram_len then -- TODO: If the character is in the line, -- then it should get a point or somethin. - return 0 + return 1 end local prompt_lower = prompt:lower() @@ -352,7 +352,7 @@ sorters.get_generic_fuzzy_sorter = function(opts) -- entry (the whole entry) scoring_function = function(_, prompt, line, _) if prompt == 0 or #prompt < ngram_len then - return 0 + return 1 end local prompt_lower = prompt:lower() @@ -484,7 +484,7 @@ sorters.highlighter_only = function(opts) return Sorter:new { scoring_function = function() - return 0 + return 1 end, highlighter = function(_, prompt, display) @@ -496,7 +496,7 @@ end sorters.empty = function() return Sorter:new { scoring_function = function() - return 0 + return 1 end, } end @@ -531,6 +531,10 @@ sorters.get_substr_matcher = function() return Sorter:new { highlighter = substr_highlighter, scoring_function = function(_, prompt, _, entry) + if #prompt == 0 then + return 1 + end + local display = entry.ordinal:lower() local search_terms = util.max_split(prompt, "%s")