0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0618: echoing a null list results in no output

Problem:    Echoing a null list results in no output. (Yegappan Lakshmanan)
Solution:   Return "[]" instead of NULL in echo_string_core().
This commit is contained in:
Bram Moolenaar
2020-04-22 19:13:19 +02:00
parent d2662ad2de
commit db950e4c03
3 changed files with 5 additions and 1 deletions

View 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)

View 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')

View File

@@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
618,
/**/
617,
/**/