Skip to content

Commit

Permalink
test: to reproduce regression or broken by vim#12971
Browse files Browse the repository at this point in the history
// to repro and test 'index out of range' err

Signed-off-by: shane.xb.qian <shane.qian@foxmail.com>
  • Loading branch information
Shane-XB-Qian committed Oct 23, 2023
1 parent 0ab500d commit 56edc64
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/testdir/test_ins_complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2279,8 +2279,16 @@ func Test_complete_info_index()
call feedkeys("Go\<C-X>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
call assert_equal("eee", g:compl_info['items'][g:compl_info['selected']]['word'])

" Check if index out of range
" https://github.com/vim/vim/pull/12971
call feedkeys("Go\<C-X>\<C-N>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])

" Add 'noselect', check that 'selected' is -1 when nothing is selected.
set completeopt+=noselect

" Search forward.
call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>_dd", 'tx')
call assert_equal(-1, g:compl_info['selected'])
Expand All @@ -2289,6 +2297,13 @@ func Test_complete_info_index()
call feedkeys("Go\<C-X>\<C-P>\<F5>\<Esc>_dd", 'tx')
call assert_equal(-1, g:compl_info['selected'])

" Check if index out of range
" https://github.com/vim/vim/pull/12971
call feedkeys("Go\<C-X>\<C-N>\<C-P>\<F5>\<Esc>_dd", 'tx')
call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])

set completeopt&
bwipe!
endfunc
Expand Down

0 comments on commit 56edc64

Please sign in to comment.