summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_popup.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-17 19:36:06 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-17 19:36:06 +0200
commite9bd57286a5cbb0e1ec18b5d194dc4af1bda9f3a (patch)
tree34510fae2da2db932e6a750cce702e3f1a4c8db2 /src/testdir/test_popup.vim
parent4dd751b95696957c7baabad2f19f9e02fc596eae (diff)
patch 8.1.1875: cannot get size and position of the popup menuv8.1.1875
Problem: Cannot get size and position of the popup menu. Solution: Add pum_getpos(). (Ben Jackson, closes #4827)
Diffstat (limited to 'src/testdir/test_popup.vim')
-rw-r--r--src/testdir/test_popup.vim44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index e7b4c7246d..d9f561bc7f 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -1033,6 +1033,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', ''])
@@ -1063,8 +1077,36 @@ func Test_CompleteChanged()
autocmd! AAAAA_Group
set complete& completeopt&
- delfunc! OnPumchange
+ delfunc! OnPumChange
+ 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