]> granicus.if.org Git - vim/commitdiff
patch 8.2.0618: echoing a null list results in no output v8.2.0618
authorBram Moolenaar <Bram@vim.org>
Wed, 22 Apr 2020 17:13:19 +0000 (19:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 22 Apr 2020 17:13:19 +0000 (19:13 +0200)
Problem:    Echoing a null list results in no output. (Yegappan Lakshmanan)
Solution:   Return "[]" instead of NULL in echo_string_core().

src/eval.c
src/testdir/test_messages.vim
src/version.c

index 43c20086c2b22e2e1ebca4cb5a4fa632825163a9..7130620c94bc9799af2fe824e6b0d8b548c4f603 100644 (file)
@@ -4528,8 +4528,9 @@ echo_string_core(
        case VAR_LIST:
            if (tv->vval.v_list == NULL)
            {
+               // NULL list is equivalent to empty list.
                *tofree = NULL;
-               r = NULL;
+               r = (char_u *)"[]";
            }
            else if (copyID != 0 && tv->vval.v_list->lv_copyID == copyID
                    && tv->vval.v_list->lv_len > 0)
index 32ffb48a8d571a77f498bc0874900afcfc245cd4..ac91aa097b202af42fbbc9bc75670cf3d1dcd41b 100644 (file)
@@ -76,6 +76,7 @@ func Test_echomsg()
   call assert_equal("\n12345", execute(':echomsg 12345'))
   call assert_equal("\n[]", execute(':echomsg []'))
   call assert_equal("\n[1, 2, 3]", execute(':echomsg [1, 2, 3]'))
+  call assert_equal("\n[1, 2, []]", execute(':echomsg [1, 2, test_null_list()]'))
   call assert_equal("\n{}", execute(':echomsg {}'))
   call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}'))
   if has('float')
index b7958da9bc02f177e3083e1ac30911b97a44172b..c08008434ca90aea7ea40bd2920bc577bd378b18 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    618,
 /**/
     617,
 /**/