]> granicus.if.org Git - vim/commitdiff
patch 8.1.1447: not allowed to create an empty popup v8.1.1447
authorBram Moolenaar <Bram@vim.org>
Sun, 2 Jun 2019 11:22:11 +0000 (13:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 2 Jun 2019 11:22:11 +0000 (13:22 +0200)
Problem:    Not allowed to create an empty popup.
Solution:   Remove restriction that there is some text. (closes #4470)

src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index dc3b56468bd21e6c78b6665f18adf9272d3abe36..4e07bdb597d64c428e48d25d8b9eb3fe69316b36 100644 (file)
@@ -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.
index 6e059193bfb8fbf8008ed6c954aae14ba0fe1d3e..4ed3b1caba63cb42da7b18a537c7c1353a6661c5 100644 (file)
@@ -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
index 597fb90fe713a1235a4c1fed83e5b6f2e12b5b16..9f316c168f3c7b75b2aa3842c0b7d379a394fba1 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1447,
 /**/
     1446,
 /**/