From 2d63b6d2c17906fafcbbfe7111202cf4c5d392af Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 30 Mar 2019 21:06:23 +0900 Subject: vim-patch:8.1.1068: cannot get all the information about current completion Problem: Cannot get all the information about current completion. Solution: Add complete_info(). (Shougo, Hirohito Higashi, closes vim/vim#4106) https://github.com/vim/vim/commit/fd133323d4e1cc9c0e61c0ce357df4d36ea148e3 --- src/nvim/testdir/test_popup.vim | 101 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 6c43cbc1dc..c8398c3afa 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -712,4 +712,105 @@ func Test_popup_and_window_resize() bwipe! endfunc +func Test_popup_complete_info_01() + new + inoremap =complete_info().mode + func s:complTestEval() abort + call complete(1, ['aa', 'ab']) + return '' + endfunc + inoremap =s:complTestEval() + call writefile([ + \ 'dummy dummy.txt 1', + \], 'Xdummy.txt') + setlocal tags=Xdummy.txt + setlocal dictionary=Xdummy.txt + setlocal thesaurus=Xdummy.txt + setlocal omnifunc=syntaxcomplete#Complete + setlocal completefunc=syntaxcomplete#Complete + setlocal spell + for [keys, mode_name] in [ + \ ["", ''], + \ ["\", 'ctrl_x'], + \ ["\\", 'keyword'], + \ ["\\", 'keyword'], + \ ["\\", 'whole_line'], + \ ["\\", 'files'], + \ ["\\", 'tags'], + \ ["\\", 'path_defines'], + \ ["\\", 'path_patterns'], + \ ["\\", 'dictionary'], + \ ["\\", 'thesaurus'], + \ ["\\", 'cmdline'], + \ ["\\", 'function'], + \ ["\\", 'omni'], + \ ["\s", 'spell'], + \ ["\", 'eval'], + \] + call feedkeys("i" . keys . "\\", 'tx') + call assert_equal(mode_name, getline('.')) + %d + endfor + call delete('Xdummy.txt') + bwipe! +endfunc + +func UserDefinedComplete(findstart, base) + if a:findstart + return 0 + else + return [ + \ { 'word': 'Jan', 'menu': 'January' }, + \ { 'word': 'Feb', 'menu': 'February' }, + \ { 'word': 'Mar', 'menu': 'March' }, + \ { 'word': 'Apr', 'menu': 'April' }, + \ { 'word': 'May', 'menu': 'May' }, + \ ] + endif +endfunc + +func GetCompleteInfo() + if empty(g:compl_what) + let g:compl_info = complete_info() + else + let g:compl_info = complete_info(g:compl_what) + endif + return '' +endfunc + +func Test_popup_complete_info_02() + new + inoremap =GetCompleteInfo() + setlocal completefunc=UserDefinedComplete + + let d = { + \ 'mode': 'function', + \ 'pum_visible': 1, + \ 'items': [ + \ {'word': 'Jan', 'menu': 'January', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, + \ {'word': 'Feb', 'menu': 'February', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, + \ {'word': 'Mar', 'menu': 'March', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, + \ {'word': 'Apr', 'menu': 'April', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, + \ {'word': 'May', 'menu': 'May', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''} + \ ], + \ 'selected': 0, + \ } + + let g:compl_what = [] + call feedkeys("i\\\", 'tx') + call assert_equal(d, g:compl_info) + + let g:compl_what = ['mode', 'pum_visible', 'selected'] + call remove(d, 'items') + call feedkeys("i\\\", 'tx') + call assert_equal(d, g:compl_info) + + let g:compl_what = ['mode'] + call remove(d, 'selected') + call remove(d, 'pum_visible') + call feedkeys("i\\\", 'tx') + call assert_equal(d, g:compl_info) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit