Skip to content

Commit

Permalink
fix(ghost_text): handle append-only textEdits
Browse files Browse the repository at this point in the history
  • Loading branch information
liskin committed Aug 21, 2024
1 parent ae644fe commit 74532ec
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/cmp/view/ghost_text_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 74532ec

Please sign in to comment.