aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/match.c4
-rw-r--r--test/old/testdir/test_match.vim5
2 files changed, 4 insertions, 5 deletions
diff --git a/src/nvim/match.c b/src/nvim/match.c
index ea8a1a05f4..580d7d1069 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -100,7 +100,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in
// Build new match.
matchitem_T *m = xcalloc(1, sizeof(matchitem_T));
- if (pos_list != NULL) {
+ if (tv_list_len(pos_list) > 0) {
m->mit_pos_array = xcalloc((size_t)tv_list_len(pos_list), sizeof(llpos_T));
m->mit_pos_count = tv_list_len(pos_list);
}
@@ -1103,7 +1103,7 @@ void f_matchaddpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
list_T *l;
l = argvars[1].vval.v_list;
- if (l == NULL) {
+ if (tv_list_len(l) == 0) {
return;
}
diff --git a/test/old/testdir/test_match.vim b/test/old/testdir/test_match.vim
index 1cb52b8b2a..ddf032d593 100644
--- a/test/old/testdir/test_match.vim
+++ b/test/old/testdir/test_match.vim
@@ -310,6 +310,7 @@ func Test_matchaddpos_error()
" call assert_fails("call matchaddpos('Error', [{}])", 'E290:')
call assert_fails("call matchaddpos('Error', [{}])", 'E5031:')
call assert_equal(-1, matchaddpos('Error', v:_null_list))
+ call assert_equal(-1, matchaddpos('Error', []))
call assert_fails("call matchaddpos('Error', [1], [], 1)", 'E745:')
endfunc
@@ -427,13 +428,11 @@ func Test_match_tab_with_linebreak()
call setline(1, "\tix")
call matchadd('ErrorMsg', '\t')
END
- call writefile(lines, 'XscriptMatchTabLinebreak')
+ call writefile(lines, 'XscriptMatchTabLinebreak', 'D')
let buf = RunVimInTerminal('-S XscriptMatchTabLinebreak', #{rows: 10})
call VerifyScreenDump(buf, 'Test_match_tab_linebreak', {})
call StopVimInTerminal(buf)
- call delete('XscriptMatchTabLinebreak')
endfunc
-
" vim: shiftwidth=2 sts=2 expandtab