patch 9.1.1020: no way to get current selected item in a async context
Problem: no way to get current selected item in a async context
Solution: add completed flag to show the entries of currently selected
index item (@glepnir)
closes: #16451
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 8b26666..289a281 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -2975,4 +2975,34 @@
set cot&
endfunc
+func Test_complete_info_completed()
+ func ShownInfo()
+ let g:compl_info = complete_info(['completed'])
+ return ''
+ endfunc
+ set completeopt+=noinsert
+
+ new
+ call setline(1, ['aaa', 'aab', 'aba', 'abb'])
+ inoremap <buffer><F5> <C-R>=ShownInfo()<CR>
+
+ call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({'word': 'aaa', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, g:compl_info['completed'])
+
+ call feedkeys("Go\<C-X>\<C-N>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({'word': 'aab', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, g:compl_info['completed'])
+
+ call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({'word': 'abb', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, g:compl_info['completed'])
+
+ set completeopt+=noselect
+ call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({}, g:compl_info)
+
+ bw!
+ bw!
+ delfunc ShownInfo
+ set cot&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable