]> granicus.if.org Git - vim/commitdiff
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead v8.0.1210
authorBram Moolenaar <Bram@vim.org>
Sun, 22 Oct 2017 12:44:17 +0000 (14:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 22 Oct 2017 12:44:17 +0000 (14:44 +0200)
Problem:    When typing a search pattern CTRL-G and CTRL-T are ignored when
            there is typeahead.
Solution:   Don't pass SEARCH_PEEK and don't call char_avail(). (haya14busa,
            closes #2233)

src/ex_getln.c
src/testdir/test_search.vim
src/version.c

index ceeeaf89f068e40de073ed530910978327c917b2..6876a215a82b305ceb487f16f6043a500be9d1b2 100644 (file)
@@ -158,6 +158,20 @@ trigger_cmd_autocmd(int typechar, int evt)
 }
 #endif
 
+/*
+ * Abandon the command line.
+ */
+    static void
+abandon_cmdline(void)
+{
+    vim_free(ccline.cmdbuff);
+    ccline.cmdbuff = NULL;
+    if (msg_scrolled == 0)
+       compute_cmdrow();
+    MSG("");
+    redraw_cmdline = TRUE;
+}
+
 /*
  * getcmdline() - accept a command line starting with firstc.
  *
@@ -1702,11 +1716,8 @@ getcmdline(
                if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
                {
                    pos_T  t;
-                   int    search_flags = SEARCH_KEEP + SEARCH_NOOF
-                                                            + SEARCH_PEEK;
+                   int    search_flags = SEARCH_KEEP + SEARCH_NOOF;
 
-                   if (char_avail())
-                       continue;
                    cursor_off();
                    out_flush();
                    if (c == Ctrl_G)
@@ -2083,15 +2094,8 @@ returncmd:
        }
 #endif
 
-       if (gotesc)         /* abandon command line */
-       {
-           vim_free(ccline.cmdbuff);
-           ccline.cmdbuff = NULL;
-           if (msg_scrolled == 0)
-               compute_cmdrow();
-           MSG("");
-           redraw_cmdline = TRUE;
-       }
+       if (gotesc)
+           abandon_cmdline();
     }
 
     /*
index e6a46ff1454cf3b98c2803b74ebcb298c1d4a6d5..19e631e6998d525f0d3be403128d1a947b00f00d 100644 (file)
@@ -356,6 +356,26 @@ func Test_search_cmdline4()
   bw!
 endfunc
 
+func Test_search_cmdline5()
+  if !exists('+incsearch')
+    return
+  endif
+  " Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
+  " regardless char_avail.
+  new
+  call setline(1, ['  1 the first', '  2 the second', '  3 the third'])
+  set incsearch
+  1
+  call feedkeys("/the\<c-g>\<c-g>\<cr>", 'tx')
+  call assert_equal('  3 the third', getline('.'))
+  $
+  call feedkeys("?the\<c-t>\<c-t>\<c-t>\<cr>", 'tx')
+  call assert_equal('  2 the second', getline('.'))
+  " clean up
+  set noincsearch
+  bw!
+endfunc
+
 " Tests for regexp with various magic settings
 func Test_search_regexp()
   enew!
index b0eefff0212edf404535bb3fa0d7520cb66c4fad..6ab48f1798874950395c05f8a8fc85bb76021028 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1210,
 /**/
     1209,
 /**/