Skip to content

Commit

Permalink
Fix #1144
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Aug 20, 2022
1 parent 3cc0c18 commit 995a2a9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/cmp/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ core.confirm = function(self, e, option, callback)
table.insert(keys, string.sub(e.context.cursor_before_line, e:get_offset()))
feedkeys.call(table.concat(keys, ''), 'in')
else
vim.cmd([[silent! undojoin]])
vim.api.nvim_buf_set_text(0, ctx.cursor.row - 1, e:get_offset() - 1, ctx.cursor.row - 1, ctx.cursor.col - 1, {
string.sub(e.context.cursor_before_line, e:get_offset()),
})
Expand Down Expand Up @@ -400,9 +401,11 @@ core.confirm = function(self, e, option, callback)
if has_cursor_line_text_edit then
return
end
vim.cmd([[silent! undojoin]])
vim.lsp.util.apply_text_edits(text_edits, ctx.bufnr, 'utf-16')
end)
else
vim.cmd([[silent! undojoin]])
vim.lsp.util.apply_text_edits(e:get_completion_item().additionalTextEdits, ctx.bufnr, 'utf-16')
end
end)
Expand Down Expand Up @@ -460,6 +463,7 @@ core.confirm = function(self, e, option, callback)
end)
feedkeys.call(keymap.indentkeys(vim.bo.indentkeys), 'n')
feedkeys.call('', 'n', function()
release()
e:execute(vim.schedule_wrap(function()
release()
self.event:emit('confirm_done', {
Expand Down

0 comments on commit 995a2a9

Please sign in to comment.