Patch 8.2.5116
Problem: "limit" option of matchfuzzy() not always respected.
Solution: Remove "else". (Kazuyuki Miyagi, closes #10586)
Files: runtime/doc/builtin.txt, src/search.c,
src/testdir/test_matchfuzzy.vim
*** ../vim-8.2.5115/runtime/doc/builtin.txt 2022-05-27 21:57:51.939739826 +0100
--- runtime/doc/builtin.txt 2022-06-17 18:26:35.720767739 +0100
***************
*** 5839,5844 ****
--- 5899,5906 ----
matchseq When this item is present return only matches
that contain the characters in {str} in the
given sequence.
+ limit Maximum number of matches in {list} to be
+ returned. Zero means no limit.
If {list} is a list of dictionaries, then the optional {dict}
argument supports the following additional items:
***************
*** 5850,5857 ****
This should accept a dictionary item as the
argument and return the text for that item to
use for fuzzy matching.
- limit Maximum number of matches in {list} to be
- returned. Zero means no limit.
{str} is treated as a literal string and regular expression
matching is NOT supported. The maximum supported {str} length
--- 5912,5917 ----
*** ../vim-8.2.5115/src/search.c 2022-06-16 21:20:43.388236870 +0100
--- src/search.c 2022-06-17 18:19:20.560629175 +0100
***************
*** 4844,4850 ****
return;
}
}
! else if ((di = dict_find(d, (char_u *)"limit", -1)) != NULL)
{
if (di->di_tv.v_type != VAR_NUMBER)
{
--- 4844,4851 ----
return;
}
}
!
! if ((di = dict_find(d, (char_u *)"limit", -1)) != NULL)
{
if (di->di_tv.v_type != VAR_NUMBER)
{
*** ../vim-8.2.5115/src/testdir/test_matchfuzzy.vim 2022-05-11 14:15:32.343235976 +0100
--- src/testdir/test_matchfuzzy.vim 2022-06-17 18:19:20.560629175 +0100
***************
*** 243,248 ****
--- 243,256 ----
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
*** ../vim-8.2.5115/src/version.c 2022-06-17 15:17:06.308400366 +0100
--- src/version.c 2022-06-17 18:22:19.210815576 +0100
***************
*** 736,737 ****
--- 736,739 ----
{ /* Add new patch number below this line */
+ /**/
+ 5116,
/**/
--
SOLDIER: What? Ridden on a horse?
ARTHUR: Yes!
SOLDIER: You're using coconuts!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///