aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSeth Fowler <seth@blackhail.net>2019-12-16 14:08:55 -0500
committerBjörn Linse <bjorn.linse@gmail.com>2019-12-16 20:08:55 +0100
commit251b20e5334e1ff8af7fdd37ca1770ad485f031b (patch)
tree132e9c9b77cb33ed92b4792b3018b271c7f246cc /src
parent473aea92cb0e987bdd89b4bd27fdc1ed22705bd6 (diff)
downloadrneovim-251b20e5334e1ff8af7fdd37ca1770ad485f031b.tar.gz
rneovim-251b20e5334e1ff8af7fdd37ca1770ad485f031b.tar.bz2
rneovim-251b20e5334e1ff8af7fdd37ca1770ad485f031b.zip
Add support for the pum_getpos() API (#11562)
Add support for the pum_getpos() API
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c7
-rw-r--r--src/nvim/eval.lua1
-rw-r--r--src/nvim/testdir/test_popup.vim42
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