From 7cd39409e7378fa711624687d3b430b8a56c3af9 Mon Sep 17 00:00:00 2001 From: hrsh7th <629908+hrsh7th@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:39:27 +0900 Subject: [PATCH] Fix #1443 --- lua/cmp/matcher.lua | 2 +- lua/cmp/matcher_spec.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/cmp/matcher.lua b/lua/cmp/matcher.lua index 5ac00bc..1ad69ca 100644 --- a/lua/cmp/matcher.lua +++ b/lua/cmp/matcher.lua @@ -198,7 +198,7 @@ end --- fuzzy matcher.fuzzy = function(input, word, matches) - local input_index = matches[1] and (matches[1].input_match_end + 1) or 1 + local input_index = matches[#matches] and (matches[#matches].input_match_end + 1) or 1 -- Lately specified middle of text. for i = 1, #matches - 1 do diff --git a/lua/cmp/matcher_spec.lua b/lua/cmp/matcher_spec.lua index d464898..6e30425 100644 --- a/lua/cmp/matcher_spec.lua +++ b/lua/cmp/matcher_spec.lua @@ -37,6 +37,9 @@ describe('matcher', function() assert.is.truthy(matcher.match('Unit', 'net.UnixListener', { disallow_partial_fuzzy_matching = true }) == 0) assert.is.truthy(matcher.match('Unit', 'net.UnixListener', { disallow_partial_fuzzy_matching = false }) >= 1) + assert.is.truthy(matcher.match('emg', 'error_msg') >= 1) + assert.is.truthy(matcher.match('sasr', 'saved_splitright') >= 1) + local score, matches score, matches = matcher.match('tail', 'HCDetails', { disallow_fuzzy_matching = false,