]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5039: confusing error if first argument of popup_create() is wrong v8.2.5039
authorBram Moolenaar <Bram@vim.org>
Sun, 29 May 2022 16:13:24 +0000 (17:13 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 29 May 2022 16:13:24 +0000 (17:13 +0100)
Problem:    Confusing error if first argument of popup_create() is wrong.
Solution:   Give a more informative error.

src/errors.h
src/popupwin.c
src/testdir/dumps/Test_popup_settext_07.dump
src/testdir/test_popupwin.vim
src/version.c

index 3e5252c76b4edf1634635c4a841a9417128ac82a..8ca2a3e2f7bb5b3251bf21a68b455ac748a31005 100644 (file)
@@ -3284,3 +3284,7 @@ EXTERN char e_bitshift_ops_must_be_number[]
 EXTERN char e_bitshift_ops_must_be_postive[]
        INIT(= N_("E1283: Bitshift amount must be a positive number"));
 #endif
+#if defined(FEAT_PROP_POPUP)
+EXTERN char e_argument_1_list_item_nr_dictionary_required[]
+       INIT(= N_("E1284: Argument 1, list item %d: Dictionary required"));
+#endif
index 96874011e6203fb0072bd4a53a67ee762b9ec4cf..5074eaa652b744f29707ab23ae60c542e032b4a0 100644 (file)
@@ -1047,7 +1047,7 @@ add_popup_dicts(buf_T *buf, list_T *l)
     {
        if (li->li_tv.v_type != VAR_DICT)
        {
-           emsg(_(e_dictionary_required));
+           semsg(_(e_argument_1_list_item_nr_dictionary_required), lnum + 1);
            return;
        }
        dict = li->li_tv.vval.v_dict;
@@ -1685,7 +1685,9 @@ popup_set_buffer_text(buf_T *buf, typval_T text)
 
        if (l != NULL && l->lv_len > 0)
        {
-           if (l->lv_first->li_tv.v_type == VAR_STRING)
+           if (l->lv_first == &range_list_item)
+               emsg(_(e_using_number_as_string));
+           else if (l->lv_first->li_tv.v_type == VAR_STRING)
                // list of strings
                add_popup_strings(buf, l);
            else
index 146dec6775de29dd9702cfa43e5a72dd1d360e20..2362aa7140f0d90ea9a1a3126a4a3fcbc2cc76d9 100644 (file)
@@ -7,4 +7,4 @@
 |~| @73
 |~| @73
 |~| @73
-|E+0#ffffff16#e000002|7|1|5|:| |D|i|c|t|i|o|n|a|r|y| |r|e|q|u|i|r|e|d| +0#0000000#ffffff0@31|0|,|0|-|1| @8|A|l@1| 
+|E+0#ffffff16#e000002|1|0|2|4|:| |U|s|i|n|g| |a| |N|u|m|b|e|r| |a|s| |a| |S|t|r|i|n|g| +0#0000000#ffffff0@23|0|,|0|-|1| @8|A|l@1| 
index 178f2356849de7ba8a85a8f318ca47735cf7187a..a78816b80fbc28a4d5b0fb9d0ccce348e5f0166a 100644 (file)
@@ -1072,7 +1072,7 @@ func Test_popup_invalid_arguments()
   call assert_fails('call popup_create("text", #{borderchars: "none"})', 'E714:')
   call popup_clear()
 
-  call assert_fails('call popup_create([#{text: "text"}, 666], {})', 'E715:')
+  call assert_fails('call popup_create([#{text: "text"}, 666], {})', 'E1284: Argument 1, list item 2: Dictionary required')
   call popup_clear()
   call assert_fails('call popup_create([#{text: "text", props: "none"}], {})', 'E714:')
   call popup_clear()
@@ -1091,6 +1091,11 @@ func Test_popup_invalid_arguments()
   call popup_clear()
   call assert_fails('call popup_create("text", #{tabpage : 4})', 'E997:')
   call popup_clear()
+
+  call assert_fails('call popup_create(range(10), {})', 'E1024:')
+  call popup_clear()
+  call assert_fails('call popup_create([1, 2], {})', 'E1284: Argument 1, list item 1: Dictionary required')
+  call popup_clear()
 endfunc
 
 func Test_win_execute_closing_curwin()
index cc9768747c985e8c949f2f87079e662d4b6ae083..9e51afe330d5f8ff3b00772a774e90d3d150a9bd 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5039,
 /**/
     5038,
 /**/