vim-patch:9.1.1337: Undo corrupted with 'completeopt' "preinsert" when switching buffer (#33600)

Problem:  Undo corrupted with 'completeopt' "preinsert" when switching
          buffer or window.
Solution: Do not delete preinsert text when switching buffer or window.
          (zeertzjq)

related: neovim/neovim#33581
closes: vim/vim#17193

1343681aba
This commit is contained in:
zeertzjq
2025-04-24 07:35:11 +08:00
committed by GitHub
parent 921752d3e2
commit 63689deb45
2 changed files with 44 additions and 2 deletions

View File

@@ -2334,9 +2334,10 @@ static bool set_ctrl_x_mode(const int c)
static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
{
// Remove pre-inserted text when present.
if (ins_compl_preinsert_effect()) {
if (ins_compl_preinsert_effect() && ins_compl_win_active(curwin)) {
ins_compl_delete(false);
}
// Get here when we have finished typing a sequence of ^N and
// ^P or other completion characters in CTRL-X mode. Free up
// memory that was used, and make sure we can redo the insert.