summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-07-01 23:11:17 +0200
committerBram Moolenaar <Bram@vim.org>2017-07-01 23:11:17 +0200
commitda5116da4586fc714434411d2cccb066caa3723e (patch)
treec2d09893bb76acd0bcddde976ab3593bc61fc829
parenta83fe75ca76f6f74daa1e5a620054b973b43379b (diff)
patch 8.0.0692: CTRL-G with 'incsearch' and ? goes in the wrong directionv8.0.0692
Problem: Using CTRL-G with 'incsearch' and ? goes in the wrong direction. (Ramel Eshed) Solution: Adjust search_start. (Christian Brabandt)
-rw-r--r--src/ex_getln.c8
-rw-r--r--src/testdir/test_search.vim34
-rw-r--r--src/version.c2
3 files changed, 44 insertions, 0 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 11de136bf7..a888ba412d 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -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 */
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 18a4577b7f..69b1335efb 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 4e7558a4b4..917eaa85d2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 692,
+/**/
691,
/**/
690,