diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2022-06-07 16:55:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-07 16:55:32 +0100 |
commit | 3cd22a34852b7453eecb4715806cc09dcc226e0c (patch) | |
tree | 4adc411be45042e7bb976d39312a97f5c2e2f80a | |
parent | 057a280867be6b4edefb1d5fb959f0aa71e7c1a5 (diff) | |
download | rneovim-3cd22a34852b7453eecb4715806cc09dcc226e0c.tar.gz rneovim-3cd22a34852b7453eecb4715806cc09dcc226e0c.tar.bz2 rneovim-3cd22a34852b7453eecb4715806cc09dcc226e0c.zip |
fix(eval/f_getmatches): return empty list for invalid win argument (#18893)
Slight inaccuracy in v8.1.1084's port.
Like Vim, it should return [], not 0.
Ref #18890
-rw-r--r-- | runtime/doc/builtin.txt | 2 | ||||
-rw-r--r-- | src/nvim/match.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 7f7b92d250..f63525242f 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -3214,7 +3214,7 @@ getmatches([{win}]) *getmatches()* |getmatches()|. If {win} is specified, use the window with this number or window ID instead of the current window. If {win} is invalid, - `0` is returned. + an empty list is returned. Example: > :echo getmatches() < [{'group': 'MyGroup1', 'pattern': 'TODO', diff --git a/src/nvim/match.c b/src/nvim/match.c index 54f3bff472..4bfc06d7e5 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -873,11 +873,11 @@ void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) int i; win_T *win = get_optional_window(argvars, 0); + tv_list_alloc_ret(rettv, kListLenMayKnow); if (win == NULL) { return; } - tv_list_alloc_ret(rettv, kListLenMayKnow); cur = win->w_match_head; while (cur != NULL) { dict_T *dict = tv_dict_alloc(); |