From 71d7f46b930bf08e982925c77bd9b0a9808c1162 Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Thu, 17 Mar 2022 15:53:10 +0900 Subject: [PATCH] Try to fix col adjustment (#843) * Try to fix col adjuastment * Improve duplicated text handling --- lua/cmp/entry.lua | 10 ++++++---- lua/cmp/view.lua | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/cmp/entry.lua b/lua/cmp/entry.lua index 8cb368d..8574b92 100644 --- a/lua/cmp/entry.lua +++ b/lua/cmp/entry.lua @@ -260,10 +260,12 @@ entry.get_vim_item = function(self, suggest_offset) end -- remove duplicated string. - for i = 1, #word - 1 do - if str.has_prefix(self.context.cursor_after_line, string.sub(word, i, #word)) then - word = string.sub(word, 1, i - 1) - break + if self:get_offset() ~= self.context.cursor.col then + for i = 1, #word - 1 do + if str.has_prefix(self.context.cursor_after_line, string.sub(word, i, #word)) then + word = string.sub(word, 1, i - 1) + break + end end end diff --git a/lua/cmp/view.lua b/lua/cmp/view.lua index 2885cb1..981378b 100644 --- a/lua/cmp/view.lua +++ b/lua/cmp/view.lua @@ -80,7 +80,7 @@ view.open = function(self, ctx, sources) -- create filtered entries. local offset = ctx.cursor.col for i, s in ipairs(source_group) do - if s.offset <= offset then + if s.offset <= ctx.cursor.col then if not has_triggered_by_symbol_source or s.is_triggered_by_symbol then -- source order priority bonus. local priority = s:get_source_config().priority or ((#source_group - (i - 1)) * config.get().sorting.priority_weight)