diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-06-02 13:22:11 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-06-02 13:22:11 +0200 |
commit | 7b29dd850752b975baef47b66c590f5e978ad847 (patch) | |
tree | c20ace7b741ac6c4e672c81ff749d4a24fd0f36f /src | |
parent | 9eaac896501bcd6abdd430a90293eae8101df24a (diff) | |
download | vim-git-7b29dd850752b975baef47b66c590f5e978ad847.tar.gz |
patch 8.1.1447: not allowed to create an empty popupv8.1.1447
Problem: Not allowed to create an empty popup.
Solution: Remove restriction that there is some text. (closes #4470)
Diffstat (limited to 'src')
-rw-r--r-- | src/popupwin.c | 23 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 14 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 27 insertions, 12 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index dc3b56468..4e07bdb59 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -488,12 +488,8 @@ popup_create(typval_T *argvars, typval_T *rettv, int atcursor) int nr; // Check arguments look OK. - if (!(argvars[0].v_type == VAR_STRING - && argvars[0].vval.v_string != NULL - && STRLEN(argvars[0].vval.v_string) > 0) - && !(argvars[0].v_type == VAR_LIST - && argvars[0].vval.v_list != NULL - && argvars[0].vval.v_list->lv_len > 0)) + if (!(argvars[0].v_type == VAR_STRING && argvars[0].vval.v_string != NULL) + && !(argvars[0].v_type == VAR_LIST && argvars[0].vval.v_list != NULL)) { emsg(_(e_listreq)); return; @@ -560,12 +556,15 @@ popup_create(typval_T *argvars, typval_T *rettv, int atcursor) { list_T *l = argvars[0].vval.v_list; - if (l->lv_first->li_tv.v_type == VAR_STRING) - // list of strings - add_popup_strings(buf, l); - else - // list of dictionaries - add_popup_dicts(buf, l); + if (l->lv_len > 0) + { + if (l->lv_first->li_tv.v_type == VAR_STRING) + // list of strings + add_popup_strings(buf, l); + else + // list of dictionaries + add_popup_dicts(buf, l); + } } // Delete the line of the empty buffer. diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 6e059193b..4ed3b1cab 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -596,3 +596,17 @@ func Test_popup_close_callback() call popup_close(winid, 'done') call assert_equal('done', g:result) endfunc + +func Test_popup_empty() + let winid = popup_create('', {'padding': [2,2,2,2]}) + redraw + let pos = popup_getpos(winid) + call assert_equal(4, pos.width) + call assert_equal(5, pos.height) + + let winid = popup_create([], {'border': []}) + redraw + let pos = popup_getpos(winid) + call assert_equal(2, pos.width) + call assert_equal(3, pos.height) +endfunc diff --git a/src/version.c b/src/version.c index 597fb90fe..9f316c168 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1447, +/**/ 1446, /**/ 1445, |