mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
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)
da5116da45
This commit is contained in:
@@ -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;
|
||||
|
@@ -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\<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
|
||||
|
@@ -6,6 +6,7 @@ local eq = helpers.eq
|
||||
local eval = helpers.eval
|
||||
local feed = helpers.feed
|
||||
local funcs = helpers.funcs
|
||||
local wait = helpers.wait
|
||||
|
||||
describe('search cmdline', function()
|
||||
local screen
|
||||
@@ -471,4 +472,113 @@ describe('search cmdline', function()
|
||||
coladd = 0, skipcol = 0, curswant = 0},
|
||||
funcs.winsaveview())
|
||||
end)
|
||||
|
||||
it("CTRL-G with 'incsearch' and ? goes in the right direction", function()
|
||||
-- oldtest: Test_search_cmdline4().
|
||||
screen:detach()
|
||||
screen = Screen.new(40, 4)
|
||||
screen:attach()
|
||||
screen:set_default_attr_ids({
|
||||
inc = {reverse = true},
|
||||
err = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
|
||||
more = { bold = true, foreground = Screen.colors.SeaGreen4 },
|
||||
tilde = { bold = true, foreground = Screen.colors.Blue1 },
|
||||
})
|
||||
command('enew!')
|
||||
funcs.setline(1, {' 1 the first', ' 2 the second', ' 3 the third'})
|
||||
command('set laststatus=0 shortmess+=s')
|
||||
command('set incsearch')
|
||||
command('$')
|
||||
-- Send the input in chunks, so the cmdline logic regards it as
|
||||
-- "interactive". This mimics Vim's test_override("char_avail").
|
||||
-- (See legacy test: test_search.vim)
|
||||
feed('?the')
|
||||
wait()
|
||||
feed('<c-g>')
|
||||
wait()
|
||||
feed('<cr>')
|
||||
screen:expect([[
|
||||
1 the first |
|
||||
2 the second |
|
||||
3 ^the third |
|
||||
?the |
|
||||
]])
|
||||
|
||||
command('$')
|
||||
feed('?the')
|
||||
wait()
|
||||
feed('<c-g>')
|
||||
wait()
|
||||
feed('<c-g>')
|
||||
wait()
|
||||
feed('<cr>')
|
||||
screen:expect([[
|
||||
1 ^the first |
|
||||
2 the second |
|
||||
3 the third |
|
||||
?the |
|
||||
]])
|
||||
|
||||
command('$')
|
||||
feed('?the')
|
||||
wait()
|
||||
feed('<c-g>')
|
||||
wait()
|
||||
feed('<c-g>')
|
||||
wait()
|
||||
feed('<c-g>')
|
||||
wait()
|
||||
feed('<cr>')
|
||||
screen:expect([[
|
||||
1 the first |
|
||||
2 ^the second |
|
||||
3 the third |
|
||||
?the |
|
||||
]])
|
||||
|
||||
command('$')
|
||||
feed('?the')
|
||||
wait()
|
||||
feed('<c-t>')
|
||||
wait()
|
||||
feed('<cr>')
|
||||
screen:expect([[
|
||||
1 ^the first |
|
||||
2 the second |
|
||||
3 the third |
|
||||
?the |
|
||||
]])
|
||||
|
||||
command('$')
|
||||
feed('?the')
|
||||
wait()
|
||||
feed('<c-t>')
|
||||
wait()
|
||||
feed('<c-t>')
|
||||
wait()
|
||||
feed('<cr>')
|
||||
screen:expect([[
|
||||
1 the first |
|
||||
2 the second |
|
||||
3 ^the third |
|
||||
?the |
|
||||
]])
|
||||
|
||||
command('$')
|
||||
feed('?the')
|
||||
wait()
|
||||
feed('<c-t>')
|
||||
wait()
|
||||
feed('<c-t>')
|
||||
wait()
|
||||
feed('<c-t>')
|
||||
wait()
|
||||
feed('<cr>')
|
||||
screen:expect([[
|
||||
1 the first |
|
||||
2 ^the second |
|
||||
3 the third |
|
||||
?the |
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user