From 74532ecf123764ee400176c24b1bd04a641d6c70 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Wed, 21 Aug 2024 22:18:11 +0100 Subject: [PATCH] fix(ghost_text): handle append-only textEdits --- lua/cmp/view/ghost_text_view.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/cmp/view/ghost_text_view.lua b/lua/cmp/view/ghost_text_view.lua index 19c951359..1af7ad9d6 100644 --- a/lua/cmp/view/ghost_text_view.lua +++ b/lua/cmp/view/ghost_text_view.lua @@ -88,6 +88,12 @@ ghost_text_view.text_gen = function(self, line, cursor_col) if self.entry:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then word = tostring(snippet.parse(word)) end + + local irange = self.entry:get_insert_range() + if irange and self.entry.source_insert_range.start.line == irange.start.line then + word = string.sub(line, self.entry:get_offset(), irange.start.character) .. word + end + local word_clen = vim.str_utfindex(word) local cword = string.sub(line, self.entry:get_offset(), cursor_col) local cword_clen = vim.str_utfindex(cword)