From efed43377bca94f3feb48809b47f5aa7de0ea9cf Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Sun, 8 Aug 2021 17:33:33 +0900 Subject: [PATCH] Improve scoring --- lua/cmp/matcher.lua | 2 +- lua/cmp/matcher_spec.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/cmp/matcher.lua b/lua/cmp/matcher.lua index f55afd1..4ac81b4 100644 --- a/lua/cmp/matcher.lua +++ b/lua/cmp/matcher.lua @@ -135,8 +135,8 @@ matcher.match = function(input, word, words) end idx = idx + 1 if s > 0 then + s = s * (m.strict_match and 1.2 or 1) score = score + (s * (1 + math.max(0, matcher.WORD_BOUNDALY_ORDER_FACTOR - (m.index - boundary_fixer)) / matcher.WORD_BOUNDALY_ORDER_FACTOR)) - score = score + (m.strict_match and 0.1 or 0) end end diff --git a/lua/cmp/matcher_spec.lua b/lua/cmp/matcher_spec.lua index a7aa66b..f46e30e 100644 --- a/lua/cmp/matcher_spec.lua +++ b/lua/cmp/matcher_spec.lua @@ -21,6 +21,7 @@ describe('matcher', function() assert.is.truthy(matcher.match('conso', 'console') > matcher.match('conso', 'ConstantSourceNode')) assert.is.truthy(matcher.match('var_', 'var_dump') >= 1) assert.is.truthy(matcher.match('my_', 'my_awesome_variable') > matcher.match('my_', 'completion_matching_strategy_list')) + assert.is.truthy(matcher.match('luacon', 'lua_context') > matcher.match('luacon', 'LuaContext')) end) it('debug', function()