From 31a145c86642575cef6e6d78184da66ca57e2767 Mon Sep 17 00:00:00 2001 From: hrsh7th <629908+hrsh7th@users.noreply.github.com> Date: Wed, 23 Nov 2022 23:44:01 +0900 Subject: [PATCH] Fix #1249 --- lua/cmp/entry.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/cmp/entry.lua b/lua/cmp/entry.lua index 4a13f12..a7aa2ff 100644 --- a/lua/cmp/entry.lua +++ b/lua/cmp/entry.lua @@ -384,8 +384,9 @@ entry.match = function(self, input, matching_config) }, } - local score, matches, _ - score, matches = matcher.match(input, self:get_filter_text(), option) + local score, matches, filter_text, _ + filter_text = self:get_filter_text() + score, matches = matcher.match(input, filter_text, option) -- Support the language server that doesn't respect VSCode's behaviors. if score == 0 then @@ -397,14 +398,17 @@ entry.match = function(self, input, matching_config) accept = accept or string.match(prefix, '^[^%a]+$') accept = accept or string.find(self:get_completion_item().textEdit.newText, prefix, 1, true) if accept then - score, matches = matcher.match(input, prefix .. self:get_filter_text(), option) + filter_text = prefix .. self:get_filter_text() + score, matches = matcher.match(input, filter_text, option) end end end end - if self:get_filter_text() ~= self:get_completion_item().label then - _, matches = matcher.match(input, self:get_completion_item().label, { synonyms = { self:get_word() } }) + local vim_item = self:get_vim_item(self:get_offset()) + if filter_text ~= vim_item.abbr then + filter_text = vim_item.abbr or vim_item.word + _, matches = matcher.match(input, filter_text, option) end return { score = score, matches = matches }