From 00c068502d170f9f9b59c4a68aa12e8835859f6c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 09:39:41 +0200 Subject: Adding upstream version 2:9.1.0199. Signed-off-by: Daniel Baumann --- src/testdir/test_ins_complete.vim | 74 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'src/testdir/test_ins_complete.vim') diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 61ddcd3..52306e8 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -412,6 +412,62 @@ func Test_completefunc_info() set completefunc& endfunc +func CompleteInfoUserDefinedFn(findstart, query) + " User defined function (i_CTRL-X_CTRL-U) + if a:findstart + return col('.') + endif + return [{'word': 'foo'}, {'word': 'bar'}, {'word': 'baz'}, {'word': 'qux'}] +endfunc + +func CompleteInfoTestUserDefinedFn(mvmt, idx, noselect) + new + if a:noselect + set completeopt=menuone,popup,noinsert,noselect + else + set completeopt=menu,preview + endif + set completefunc=CompleteInfoUserDefinedFn + call feedkeys("i\\" . a:mvmt . "\\=string(complete_info())\\", "tx") + let completed = a:idx != -1 ? ['foo', 'bar', 'baz', 'qux']->get(a:idx) : '' + call assert_equal(completed. "{'pum_visible': 1, 'mode': 'function', 'selected': " . a:idx . ", 'items': [" . + \ "{'word': 'foo', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, " . + \ "{'word': 'bar', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, " . + \ "{'word': 'baz', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, " . + \ "{'word': 'qux', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}" . + \ "]}", getline(1)) + bwipe! + set completeopt& + set completefunc& +endfunc + +func Test_complete_info_user_defined_fn() + " forward + call CompleteInfoTestUserDefinedFn("\\", 1, v:true) + call CompleteInfoTestUserDefinedFn("\\\", 2, v:true) + call CompleteInfoTestUserDefinedFn("\\", 2, v:false) + call CompleteInfoTestUserDefinedFn("\\\", 3, v:false) + call CompleteInfoTestUserDefinedFn("\\\\", -1, v:false) + " backward + call CompleteInfoTestUserDefinedFn("\\", 2, v:true) + call CompleteInfoTestUserDefinedFn("\\\", 1, v:true) + call CompleteInfoTestUserDefinedFn("\\\\\", -1, v:true) + call CompleteInfoTestUserDefinedFn("\\", 3, v:false) + call CompleteInfoTestUserDefinedFn("\\\", 2, v:false) + " forward backward + call CompleteInfoTestUserDefinedFn("\\\\", 1, v:true) + call CompleteInfoTestUserDefinedFn("\\\", 0, v:true) + call CompleteInfoTestUserDefinedFn("\\\\", 2, v:false) + call CompleteInfoTestUserDefinedFn("\\\\\", 3, v:false) + call CompleteInfoTestUserDefinedFn("\\\", 1, v:false) + " backward forward + call CompleteInfoTestUserDefinedFn("\\\\\\", 0, v:true) + call CompleteInfoTestUserDefinedFn("\\\\", 2, v:true) + call CompleteInfoTestUserDefinedFn("\\\\\\", 1, v:false) + call CompleteInfoTestUserDefinedFn("\\\\", 3, v:false) + call CompleteInfoTestUserDefinedFn("\\\", 1, v:false) +endfunc + " Test that mouse scrolling/movement should not interrupt completion. func Test_mouse_scroll_move_during_completion() new @@ -2345,7 +2401,7 @@ func Test_complete_info_index() call assert_equal(-1, g:compl_info['selected']) call feedkeys("Go\\\\\_dd", 'tx') - call assert_equal(0, g:compl_info['selected']) + call assert_equal(5, g:compl_info['selected']) call assert_equal(6 , len(g:compl_info['items'])) call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word']) call feedkeys("Go\\\\\\\\\\\\_dd", 'tx') @@ -2359,4 +2415,18 @@ func Test_complete_info_index() bwipe! endfunc -" vim: shiftwidth=2 sts=2 expandtab +func Test_complete_changed_complete_info() + CheckRunVimInTerminal + " this used to crash vim, see #13929 + let lines =<< trim END + set completeopt=menuone + autocmd CompleteChanged * call complete_info(['items']) + call feedkeys("iii\\") + END + call writefile(lines, 'Xsegfault', 'D') + let buf = RunVimInTerminal('-S Xsegfault', #{rows: 5}) + call WaitForAssert({-> assert_match('^ii', term_getline(buf, 1))}, 1000) + call StopVimInTerminal(buf) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab nofoldenable -- cgit v1.2.3