]> granicus.if.org Git - vim/commitdiff
patch 8.0.0692: CTRL-G with 'incsearch' and ? goes in the wrong direction v8.0.0692
authorBram Moolenaar <Bram@vim.org>
Sat, 1 Jul 2017 21:11:17 +0000 (23:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 1 Jul 2017 21:11:17 +0000 (23:11 +0200)
Problem:    Using CTRL-G with 'incsearch' and ? goes in the wrong direction.
            (Ramel Eshed)
Solution:   Adjust search_start. (Christian Brabandt)

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

index 11de136bf78c5d0c57df9897e6c1e04537e0e6a5..a888ba412dfbf4dc49d85617400c8fd7c9567081 100644 (file)
@@ -1708,6 +1708,14 @@ getcmdline(
                            search_start = t;
                            (void)decl(&search_start);
                        }
+                       else if (c == Ctrl_G && firstc == '?')
+                       {
+                           /* move just after the current match, so that
+                            * when nv_search finishes the cursor will be
+                            * put back on the match */
+                           search_start = t;
+                           (void)incl(&search_start);
+                       }
                        if (LT_POS(t, search_start) && c == Ctrl_G)
                        {
                            /* wrap around */
index 18a4577b7f7fbcb15e6e089b2b201655b0fd41a0..69b1335efbd430fed347819a8c234a181e76bc84 100644 (file)
@@ -322,3 +322,37 @@ func Test_search_cmdline3()
   call test_override("char_avail", 0)
   bw!
 endfunc
+
+func Test_search_cmdline4()
+  if !exists('+incsearch')
+    return
+  endif
+  " need to disable char_avail,
+  " so that expansion of commandline works
+  call test_override("char_avail", 1)
+  new
+  call setline(1, ['  1 the first', '  2 the second', '  3 the third'])
+  set incsearch
+  $
+  call feedkeys("?the\<c-g>\<cr>", 'tx')
+  call assert_equal('  3 the third', getline('.'))
+  $
+  call feedkeys("?the\<c-g>\<c-g>\<cr>", 'tx')
+  call assert_equal('  1 the first', getline('.'))
+  $
+  call feedkeys("?the\<c-g>\<c-g>\<c-g>\<cr>", 'tx')
+  call assert_equal('  2 the second', getline('.'))
+  $
+  call feedkeys("?the\<c-t>\<cr>", 'tx')
+  call assert_equal('  1 the first', getline('.'))
+  $
+  call feedkeys("?the\<c-t>\<c-t>\<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
+  call test_override("char_avail", 0)
+  bw!
+endfunc
index 4e7558a4b42ad0f97e08cd4d74c0e24351813dff..917eaa85d26056f28263ae13ee66ad21f8978f50 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    692,
 /**/
     691,
 /**/