From 995a2a9f651dcd6cde0419129b28f53d3e274a33 Mon Sep 17 00:00:00 2001 From: hrsh7th <629908+hrsh7th@users.noreply.github.com> Date: Sun, 21 Aug 2022 01:56:04 +0900 Subject: [PATCH] Fix #1144 --- lua/cmp/core.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/cmp/core.lua b/lua/cmp/core.lua index 635fc85fb..44f51af17 100644 --- a/lua/cmp/core.lua +++ b/lua/cmp/core.lua @@ -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()), }) @@ -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) @@ -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', {