]> granicus.if.org Git - vim/commitdiff
patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped v8.2.1762
authorBram Moolenaar <Bram@vim.org>
Sun, 27 Sep 2020 18:13:03 +0000 (20:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 27 Sep 2020 18:13:03 +0000 (20:13 +0200)
Problem:    When a timer uses :stopinsert Insert mode completion isn't
            stopped. (Stanley Chan)
Solution:   Call ins_compl_prep(ESC).

src/edit.c
src/testdir/dumps/Test_pum_stopped_by_timer.dump [new file with mode: 0644]
src/testdir/test_ins_complete.vim
src/version.c

index 642ff958bd28d4ff427ecb7056b93a4cace84371..e3e4624fb0f7de089f218531e9597abfa282fe70 100644 (file)
@@ -587,8 +587,11 @@ edit(
                if (stop_insert_mode)
                {
                    // Insert mode ended, possibly from a callback.
+                   if (c != K_IGNORE && c != K_NOP)
+                       vungetc(c);
                    count = 0;
                    nomove = TRUE;
+                   ins_compl_prep(ESC);
                    goto doESCkey;
                }
            } while (c == K_IGNORE || c == K_NOP);
diff --git a/src/testdir/dumps/Test_pum_stopped_by_timer.dump b/src/testdir/dumps/Test_pum_stopped_by_timer.dump
new file mode 100644 (file)
index 0000000..77ad5ce
--- /dev/null
@@ -0,0 +1,12 @@
+|h+0&#ffffff0|e|l@1|o| @69
+|h|u|l@1|o| @69
+|h|e@2>e| @69
+|h|e|l@1|o| @69
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|3|,|5| @10|A|l@1| 
index f77512ae186a9224a23ebdf99b4fd233a82f7fb0..005e14caf091077541bf9e42a0fa3cf0f329642d 100644 (file)
@@ -407,6 +407,28 @@ func Test_ins_completeslash()
   set completeslash=
 endfunc
 
+func Test_pum_stopped_by_timer()
+  CheckScreendump
+
+  let lines =<< trim END
+    call setline(1, ['hello', 'hullo', 'heeee', ''])
+    func StartCompl()
+      call timer_start(100, { -> execute('stopinsert') })
+      call feedkeys("Gah\<C-N>")
+    endfunc
+  END
+
+  call writefile(lines, 'Xpumscript')
+  let buf = RunVimInTerminal('-S Xpumscript', #{rows: 12})
+  call term_sendkeys(buf, ":call StartCompl()\<CR>")
+  call TermWait(buf, 200)
+  call term_sendkeys(buf, "k")
+  call VerifyScreenDump(buf, 'Test_pum_stopped_by_timer', {})
+
+  call StopVimInTerminal(buf)
+  call delete('Xpumscript')
+endfunc
+
 func Test_pum_with_folds_two_tabs()
   CheckScreendump
 
index ccedf6476d1b6de3e15900ad9ec07829814a3d2d..d6006185cc55f2de0aa225a3f8659440da923062 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1762,
 /**/
     1761,
 /**/