patch 8.2.0748: cannot get a list of all popups
Problem: Cannot get a list of all popups.
Solution: Add popup_list(). Use it in the test runner.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index c010116..c499890 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -715,6 +715,7 @@
{"popup_getoptions", 1, 1, FEARG_1, ret_dict_any, PROP_FUNC(f_popup_getoptions)},
{"popup_getpos", 1, 1, FEARG_1, ret_dict_any, PROP_FUNC(f_popup_getpos)},
{"popup_hide", 1, 1, FEARG_1, ret_void, PROP_FUNC(f_popup_hide)},
+ {"popup_list", 0, 0, 0, ret_list_number, PROP_FUNC(f_popup_list)},
{"popup_locate", 2, 2, 0, ret_number, PROP_FUNC(f_popup_locate)},
{"popup_menu", 2, 2, FEARG_1, ret_number, PROP_FUNC(f_popup_menu)},
{"popup_move", 2, 2, FEARG_1, ret_void, PROP_FUNC(f_popup_move)},
diff --git a/src/popupwin.c b/src/popupwin.c
index f1f9f60..a244c32 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2720,6 +2720,25 @@
hash_unlock(&dict->dv_hashtab);
}
}
+
+/*
+ * popup_list()
+ */
+ void
+f_popup_list(typval_T *argvars UNUSED, typval_T *rettv)
+{
+ win_T *wp;
+ tabpage_T *tp;
+
+ if (rettv_list_alloc(rettv) != OK)
+ return;
+ FOR_ALL_POPUPWINS(wp)
+ list_append_number(rettv->vval.v_list, wp->w_id);
+ FOR_ALL_TABPAGES(tp)
+ FOR_ALL_POPUPWINS_IN_TAB(tp, wp)
+ list_append_number(rettv->vval.v_list, wp->w_id);
+}
+
/*
* popup_locate({row}, {col})
*/
diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro
index 4fa3013..02cdce3 100644
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -40,6 +40,7 @@
void f_popup_move(typval_T *argvars, typval_T *rettv);
void f_popup_setoptions(typval_T *argvars, typval_T *rettv);
void f_popup_getpos(typval_T *argvars, typval_T *rettv);
+void f_popup_list(typval_T *argvars, typval_T *rettv);
void f_popup_locate(typval_T *argvars, typval_T *rettv);
void f_popup_getoptions(typval_T *argvars, typval_T *rettv);
int error_if_term_popup_window(void);
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index b9d85f4..b1e0528 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -188,8 +188,9 @@
au!
au SwapExists * call HandleSwapExists()
- " Close any stray popup windows.
+ " Check for and close any stray popup windows.
if has('popupwin')
+ call assert_equal([], popup_list())
call popup_clear(1)
endif
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 5eecb19..a664346 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -428,7 +428,7 @@
call delete('XtestPopupNospace')
endfunc
-func Test_popup_firstline()
+func Test_popup_firstline_dump()
CheckScreendump
let lines =<< trim END
@@ -449,7 +449,9 @@
" clean up
call StopVimInTerminal(buf)
call delete('XtestPopupFirstline')
+endfunc
+func Test_popup_firstline()
let winid = popup_create(['1111', '222222', '33333', '44444'], #{
\ maxheight: 2,
\ firstline: 3,
@@ -491,6 +493,7 @@
call popup_setoptions(winid, #{line: 3})
call assert_equal(0, popup_getoptions(winid).firstline)
call assert_equal(10, popup_getpos(winid).firstline)
+ call popup_close(winid)
" CTRL-D scrolls down half a page
let winid = popup_create(['xxx']->repeat(50), #{
@@ -826,10 +829,13 @@
endfunc
func Test_popup_valid_arguments()
+ call assert_equal(0, len(popup_list()))
+
" Zero value is like the property wasn't there
let winid = popup_create("text", #{col: 0})
let pos = popup_getpos(winid)
call assert_inrange(&columns / 2 - 1, &columns / 2 + 1, pos.col)
+ call assert_equal([winid], popup_list())
call popup_clear()
" using cursor column has minimum value of 1
@@ -1619,12 +1625,14 @@
let pos = popup_getpos(winid)
call assert_equal(5, pos.width)
call assert_equal(5, pos.height)
+ call popup_close(winid)
let winid = popup_create([], #{border: []})
redraw
let pos = popup_getpos(winid)
call assert_equal(3, pos.width)
call assert_equal(3, pos.height)
+ call popup_close(winid)
endfunc
func Test_popup_never_behind()
@@ -3323,8 +3331,9 @@
set signcolumn=yes
call setline(1, repeat('=', &columns))
normal! ggg$
- call popup_atcursor(repeat('x', 500), #{moved: 'any', border: []})
+ let winid = popup_atcursor(repeat('x', 500), #{moved: 'any', border: []})
+ call popup_close(winid)
bwipe!
set signcolumn&
endfunc
diff --git a/src/version.c b/src/version.c
index 15956bb..7881e32 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 748,
+/**/
747,
/**/
746,