From 3b4881afc292e226e4464ef7c8c1e2506f12a173 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 5 May 2022 06:07:07 +0800 Subject: [PATCH] vim-patch:8.2.4865: :startinsert right after :stopinsert may not work Problem: :startinsert right after :stopinsert does not work when popup menu is still visible. Solution: Use ins_compl_active() instead of pum_visible(). (closes vim/vim#10352) https://github.com/vim/vim/commit/cd5dbad184e8235beb13dcd8a22302da09db9766 (cherry picked from commit 97d86c45afa02c78b1dc5d2f18316b25f819652b) --- src/nvim/edit.c | 2 +- src/nvim/testdir/test_ins_complete.vim | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 47d491033b..ce0fd1673f 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -553,7 +553,7 @@ static int insert_check(VimState *state) Insstart_orig = Insstart; } - if (stop_insert_mode && !pum_visible()) { + if (stop_insert_mode && !compl_started) { // ":stopinsert" used or 'insertmode' reset s->count = 0; return 0; // exit insert mode diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 24eaf9e8b1..90b57323af 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -516,6 +516,15 @@ func Test_pum_stopped_by_timer() call delete('Xpumscript') endfunc +func Test_complete_stopinsert_startinsert() + nnoremap startinsert + inoremap stopinsert + " This just checks if this causes an error + call feedkeys("i\\\\", 'x') + nunmap + iunmap +endfunc + func Test_pum_with_folds_two_tabs() CheckScreendump