diff options
-rw-r--r-- | runtime/doc/builtin.txt | 2 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 2 | ||||
-rw-r--r-- | src/nvim/eval.lua | 2 | ||||
-rw-r--r-- | src/nvim/search.c | 6 | ||||
-rw-r--r-- | test/old/testdir/test_matchfuzzy.vim | 16 |
5 files changed, 19 insertions, 9 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index a4adfb3a63..3ad5d83ac2 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -6412,7 +6412,7 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* returned. Zero means no limit. camelcase Use enhanced camel case scoring making results better suited for completion related to - programming languages. Default is v:true + programming languages. Defaults to v:true. If {list} is a list of dictionaries, then the optional {dict} argument supports the following additional items: diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 69e739225f..813a89898e 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -5817,7 +5817,7 @@ function vim.fn.matchend(expr, pat, start, count) end --- returned. Zero means no limit. --- camelcase Use enhanced camel case scoring making results --- better suited for completion related to ---- programming languages. Default is v:true +--- programming languages. Defaults to v:true. --- --- If {list} is a list of dictionaries, then the optional {dict} --- argument supports the following additional items: diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index f02f5179c7..ffdbacb2b4 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -7152,7 +7152,7 @@ M.funcs = { returned. Zero means no limit. camelcase Use enhanced camel case scoring making results better suited for completion related to - programming languages. Default is v:true + programming languages. Defaults to v:true. If {list} is a list of dictionaries, then the optional {dict} argument supports the following additional items: diff --git a/src/nvim/search.c b/src/nvim/search.c index fed8867315..fe8e54fed4 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3466,7 +3466,7 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv, if ((di = tv_dict_find(d, "key", -1)) != NULL) { if (di->di_tv.v_type != VAR_STRING || di->di_tv.vval.v_string == NULL || *di->di_tv.vval.v_string == NUL) { - semsg(_(e_invarg2), tv_get_string(&di->di_tv)); + semsg(_(e_invargNval), "key", tv_get_string(&di->di_tv)); return; } key = tv_get_string(&di->di_tv); @@ -3477,7 +3477,7 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv, 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)); + semsg(_(e_invargval), "limit"); return; } max_matches = (int)tv_get_number_chk(&di->di_tv, NULL); @@ -3485,7 +3485,7 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv, if ((di = tv_dict_find(d, "camelcase", -1)) != NULL) { if (di->di_tv.v_type != VAR_BOOL) { - semsg(_(e_invarg2), "camelcase"); + semsg(_(e_invargval), "camelcase"); return; } camelcase = tv_get_bool_chk(&di->di_tv, NULL); diff --git a/test/old/testdir/test_matchfuzzy.vim b/test/old/testdir/test_matchfuzzy.vim index 214862e9a0..10480f446d 100644 --- a/test/old/testdir/test_matchfuzzy.vim +++ b/test/old/testdir/test_matchfuzzy.vim @@ -78,6 +78,7 @@ func Test_matchfuzzy() " Nvim's callback implementation is different, so E6000 is expected instead, " call assert_fails("let x = matchfuzzy(l, 'cam', {'text_cb' : []})", 'E921:') call assert_fails("let x = matchfuzzy(l, 'cam', {'text_cb' : []})", 'E6000:') + call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : 123})", 'E475: Invalid value for argument key: 123') call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : []})", 'E730:') call assert_fails("let x = matchfuzzy(l, 'cam', v:_null_dict)", 'E1297:') call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : v:_null_string})", 'E475:') @@ -91,10 +92,15 @@ func Test_matchfuzzy() call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : 'name'})", 'E730:') " camelcase - call assert_equal(['Cursor', 'CurSearch', 'CursorLine', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor'], - \ matchfuzzy(['Cursor', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'CurSearch', 'CursorLine'], 'Cur', {"camelcase": v:false})) call assert_equal(['lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'Cursor', 'CurSearch', 'CursorLine'], \ matchfuzzy(['Cursor', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'CurSearch', 'CursorLine'], 'Cur')) + call assert_equal(['lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'Cursor', 'CurSearch', 'CursorLine'], + \ matchfuzzy(['Cursor', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'CurSearch', 'CursorLine'], 'Cur', {"camelcase": v:true})) + call assert_equal(['Cursor', 'CurSearch', 'CursorLine', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor'], + \ matchfuzzy(['Cursor', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'CurSearch', 'CursorLine'], 'Cur', {"camelcase": v:false})) + call assert_equal(['things', 'sThings', 'thisThings'], + \ matchfuzzy(['things','sThings', 'thisThings'], 'thin', {'camelcase': v:false})) + call assert_fails("let x = matchfuzzy([], 'foo', {'camelcase': []})", 'E475: Invalid value for argument camelcase') " Test in latin1 encoding let save_enc = &encoding @@ -161,6 +167,7 @@ func Test_matchfuzzypos() " Nvim's callback implementation is different, so E6000 is expected instead, " call assert_fails("let x = matchfuzzypos(l, 'cam', {'text_cb' : []})", 'E921:') call assert_fails("let x = matchfuzzypos(l, 'cam', {'text_cb' : []})", 'E6000:') + call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : 123})", 'E475: Invalid value for argument key: 123') call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : []})", 'E730:') call assert_fails("let x = matchfuzzypos(l, 'cam', v:_null_dict)", 'E1297:') call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : v:_null_string})", 'E475:') @@ -185,11 +192,13 @@ func Test_matchfuzzypos() " camelcase call assert_equal([['lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'Cursor', 'CurSearch', 'CursorLine'], [[1, 2, 3], [2, 3, 4], [2, 3, 4], [6, 7, 8], [0, 1, 2], [0, 1, 2], [0, 1, 2]], [318, 311, 308, 303, 267, 264, 263]], \ matchfuzzypos(['Cursor', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'CurSearch', 'CursorLine'], 'Cur')) - + call assert_equal([['lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'Cursor', 'CurSearch', 'CursorLine'], [[1, 2, 3], [2, 3, 4], [2, 3, 4], [6, 7, 8], [0, 1, 2], [0, 1, 2], [0, 1, 2]], [318, 311, 308, 303, 267, 264, 263]], + \ matchfuzzypos(['Cursor', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'CurSearch', 'CursorLine'], 'Cur', {"camelcase": v:true})) call assert_equal([['Cursor', 'CurSearch', 'CursorLine', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor'], [[0, 1, 2], [0, 1, 2], [0, 1, 2], [1, 2, 3], [2, 3, 4], [2, 3, 4], [6, 7, 8]], [267, 264, 263, 246, 239, 236, 231]], \ matchfuzzypos(['Cursor', 'lCursor', 'shCurlyIn', 'shCurlyError', 'TracesCursor', 'CurSearch', 'CursorLine'], 'Cur', {"camelcase": v:false})) call assert_equal([['things', 'sThings', 'thisThings'], [[0, 1, 2, 3], [1, 2, 3, 4], [0, 1, 2, 7]], [333, 287, 279]], \ matchfuzzypos(['things','sThings', 'thisThings'], 'thin', {'camelcase': v:false})) + call assert_fails("let x = matchfuzzypos([], 'foo', {'camelcase': []})", 'E475: Invalid value for argument camelcase') endfunc " Test for matchfuzzy() with multibyte characters @@ -280,6 +289,7 @@ 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:') + call assert_fails("call matchfuzzy(x, '2', #{limit: []})", '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}})) |