From cb67fe9093b2a68695618839691310345b5bdc62 Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Sun, 8 Aug 2021 17:37:02 +0900 Subject: [PATCH] Fix fuzzy match bug --- lua/cmp/matcher.lua | 2 +- lua/cmp/matcher_spec.lua | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/cmp/matcher.lua b/lua/cmp/matcher.lua index 4ac81b4..5389b92 100644 --- a/lua/cmp/matcher.lua +++ b/lua/cmp/matcher.lua @@ -187,7 +187,7 @@ matcher.fuzzy = function(input, word, matches) end word_offset = word_offset + 1 end - if input_index >= #input then + if input_index > #input then return true end return false diff --git a/lua/cmp/matcher_spec.lua b/lua/cmp/matcher_spec.lua index f46e30e..8bc5e15 100644 --- a/lua/cmp/matcher_spec.lua +++ b/lua/cmp/matcher_spec.lua @@ -22,14 +22,13 @@ describe('matcher', function() 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')) + assert.is.truthy(matcher.match('call', 'calc') == 0) end) it('debug', function() - assert.is.truthy(true) - matcher.debug = function(...) print(vim.inspect({ ... })) end - print('score', matcher.match('vsnipnextjump', 'vsnip-jump-next')) + -- print('score', matcher.match('vsnipnextjump', 'vsnip-jump-next')) end) end)