diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/search.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_matchfuzzy.vim | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index 4243dce479..d442a5aa87 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -5239,7 +5239,9 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv, } else if (!tv_dict_get_callback(d, "text_cb", -1, &cb)) { semsg(_(e_invargval), "text_cb"); return; - } else if ((di = tv_dict_find(d, "limit", -1)) != NULL) { + } + + if ((di = tv_dict_find(d, "limit", -1)) != NULL) { if (di->di_tv.v_type != VAR_NUMBER) { semsg(_(e_invarg2), tv_get_string(&di->di_tv)); return; diff --git a/src/nvim/testdir/test_matchfuzzy.vim b/src/nvim/testdir/test_matchfuzzy.vim index 533aec8d9a..6b4949ad8c 100644 --- a/src/nvim/testdir/test_matchfuzzy.vim +++ b/src/nvim/testdir/test_matchfuzzy.vim @@ -258,6 +258,14 @@ func Test_matchfuzzy_limit() call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 2})) call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 3})) call assert_fails("call matchfuzzy(x, '2', #{limit: '2'})", 'E475:') + + let l = [{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}] + call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{text_cb: {v -> v.val}})) + call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{key: 'val'})) + call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{text_cb: {v -> v.val}, limit: 0})) + call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{key: 'val', limit: 0})) + call assert_equal([{'id': 5, 'val': 'crayon'}], l->matchfuzzy('c', #{text_cb: {v -> v.val}, limit: 1})) + call assert_equal([{'id': 5, 'val': 'crayon'}], l->matchfuzzy('c', #{key: 'val', limit: 1})) endfunc " vim: shiftwidth=2 sts=2 expandtab |