Mercurial > vim
changeset 20126:831b1ea43020 v8.2.0618
patch 8.2.0618: echoing a null list results in no output
Commit: https://github.com/vim/vim/commit/db950e4c0318c084c31bc7b50665284f4a47c285
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Apr 22 19:13:19 2020 +0200
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().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 22 Apr 2020 19:15:04 +0200 |
parents | 4d065d193bf6 |
children | a62c4185482f |
files | src/eval.c src/testdir/test_messages.vim src/version.c |
diffstat | 3 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -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)
--- a/src/testdir/test_messages.vim +++ b/src/testdir/test_messages.vim @@ -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')