From ba47440a97710d0f4f63eea2bc196fe17297e4ae Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Mon, 14 Feb 2022 13:26:36 +0900 Subject: [PATCH] Improve common string mapping instruction --- doc/cmp.txt | 4 +--- lua/cmp/core.lua | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/cmp.txt b/doc/cmp.txt index f0bbd78..518e0d8 100644 --- a/doc/cmp.txt +++ b/doc/cmp.txt @@ -211,9 +211,7 @@ NOTE: You can call these functions in mapping via `lua require('cmp').compl mapping = { [''] = cmp.mapping(function(fallback) if cmp.visible() then - if cmp.complete_common_string() then - return - end + return cmp.complete_common_string() end fallback() end, { 'i', 'c' }), diff --git a/lua/cmp/core.lua b/lua/cmp/core.lua index 2aea557..cc26d74 100644 --- a/lua/cmp/core.lua +++ b/lua/cmp/core.lua @@ -249,7 +249,7 @@ core.complete_common_string = function(self) common_string = str.get_common_string(common_string, vim_item.word) end end - if common_string and #common_string >= (1 + cursor[2] - offset) then + if common_string and #common_string > (1 + cursor[2] - offset) then feedkeys.call(keymap.backspace(string.sub(api.get_current_line(), offset, cursor[2])) .. common_string, 'n') return true end