From 7d12597d29e60239fd5c586417b48982893c174e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 1 Feb 2018 23:50:12 +0100 Subject: vim-patch:8.0.0692: CTRL-G with 'incsearch' and ? goes in the wrong direction Problem: Using CTRL-G with 'incsearch' and ? goes in the wrong direction. (Ramel Eshed) Solution: Adjust search_start. (Christian Brabandt) https://github.com/vim/vim/commit/da5116da4586fc714434411d2cccb066caa3723e --- src/nvim/ex_getln.c | 7 +++++++ src/nvim/testdir/test_search.vim | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index bbe1d22473..c99ae687bb 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1063,6 +1063,13 @@ static void command_line_next_incsearch(CommandLineState *s, bool next_match) s->search_start = t; (void)decl(&s->search_start); } + else if (next_match && s->firstc == '?') { + // move just after the current match, so that + // when nv_search finishes the cursor will be + // put back on the match + s->search_start = t; + (void)incl(&s->search_start); + } if (lt(t, s->search_start) && next_match) { // wrap around s->search_start = t; diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 6276eb2a34..af077c16c2 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -327,3 +327,39 @@ func Test_search_cmdline3() call test_override("char_avail", 0) bw! endfunc + +func Test_search_cmdline4() + " See test/functional/legacy/search_spec.lua + throw 'skipped: Nvim does not support test_override()' + 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\\", 'tx') + call assert_equal(' 3 the third', getline('.')) + $ + call feedkeys("?the\\\", 'tx') + call assert_equal(' 1 the first', getline('.')) + $ + call feedkeys("?the\\\\", 'tx') + call assert_equal(' 2 the second', getline('.')) + $ + call feedkeys("?the\\", 'tx') + call assert_equal(' 1 the first', getline('.')) + $ + call feedkeys("?the\\\", 'tx') + call assert_equal(' 3 the third', getline('.')) + $ + call feedkeys("?the\\\\", 'tx') + call assert_equal(' 2 the second', getline('.')) + " clean up + set noincsearch + call test_override("char_avail", 0) + bw! +endfunc -- cgit