mirror of
https://github.com/vim/vim.git
synced 2025-10-11 06:34:16 -04:00
patch 8.1.1875: cannot get size and position of the popup menu
Problem: Cannot get size and position of the popup menu. Solution: Add pum_getpos(). (Ben Jackson, closes #4827)
This commit is contained in:
@@ -234,6 +234,7 @@ static void f_pow(typval_T *argvars, typval_T *rettv);
|
||||
#endif
|
||||
static void f_prevnonblank(typval_T *argvars, typval_T *rettv);
|
||||
static void f_printf(typval_T *argvars, typval_T *rettv);
|
||||
static void f_pum_getpos(typval_T *argvars, typval_T *rettv);
|
||||
static void f_pumvisible(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_PYTHON3
|
||||
static void f_py3eval(typval_T *argvars, typval_T *rettv);
|
||||
@@ -741,6 +742,7 @@ static funcentry_T global_functions[] =
|
||||
{"prop_type_get", 1, 2, 0, f_prop_type_get},
|
||||
{"prop_type_list", 0, 1, 0, f_prop_type_list},
|
||||
#endif
|
||||
{"pum_getpos", 0, 0, 0, f_pum_getpos},
|
||||
{"pumvisible", 0, 0, 0, f_pumvisible},
|
||||
#ifdef FEAT_PYTHON3
|
||||
{"py3eval", 1, 1, 0, f_py3eval},
|
||||
@@ -7960,6 +7962,19 @@ f_printf(typval_T *argvars, typval_T *rettv)
|
||||
did_emsg |= saved_did_emsg;
|
||||
}
|
||||
|
||||
/*
|
||||
* "pum_getpos()" function
|
||||
*/
|
||||
static void
|
||||
f_pum_getpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
{
|
||||
if (rettv_dict_alloc(rettv) != OK)
|
||||
return;
|
||||
#ifdef FEAT_INS_EXPAND
|
||||
pum_set_event_info(rettv->vval.v_dict);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* "pumvisible()" function
|
||||
*/
|
||||
|
@@ -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
|
||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1875,
|
||||
/**/
|
||||
1874,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user