diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 7 | ||||
-rw-r--r-- | src/nvim/eval.lua | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 42 |
3 files changed, 50 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a556f0bbbe..4c76b1b2e8 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -13972,6 +13972,13 @@ static void f_printf(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } +// "pum_getpos()" function +static void f_pum_getpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + tv_dict_alloc_ret(rettv); + pum_set_event_info(rettv->vval.v_dict); +} + /* * "pumvisible()" function */ diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0ae250e626..efeac70816 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -243,6 +243,7 @@ return { pow={args=2}, prevnonblank={args=1}, printf={args=varargs(1)}, + pum_getpos={}, pumvisible={}, py3eval={args=1}, pyeval={args=1}, diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 8083672808..9db6112eeb 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -918,6 +918,20 @@ func Test_popup_complete_info_02() bwipe! endfunc +func Test_popup_complete_info_no_pum() + new + call assert_false( pumvisible() ) + let no_pum_info = complete_info() + let d = { + \ 'mode': '', + \ 'pum_visible': 0, + \ 'items': [], + \ 'selected': -1, + \ } + call assert_equal( d, complete_info() ) + bwipe! +endfunc + func Test_CompleteChanged() new call setline(1, ['foo', 'bar', 'foobar', '']) @@ -952,4 +966,32 @@ func Test_CompleteChanged() bw! endfunc +function! GetPumPosition() + call assert_true( pumvisible() ) + let g:pum_pos = pum_getpos() + return '' +endfunction + +func Test_pum_getpos() + new + inoremap <buffer><F5> <C-R>=GetPumPosition()<CR> + setlocal completefunc=UserDefinedComplete + + let d = { + \ 'height': 5, + \ 'width': 15, + \ 'row': 1, + \ 'col': 0, + \ 'size': 5, + \ 'scrollbar': v:false, + \ } + call feedkeys("i\<C-X>\<C-U>\<F5>", 'tx') + call assert_equal(d, g:pum_pos) + + call assert_false( pumvisible() ) + call assert_equal( {}, pum_getpos() ) + bw! + unlet g:pum_pos +endfunc + " vim: shiftwidth=2 sts=2 expandtab |