0
0
mirror of https://github.com/vim/vim.git synced 2025-07-25 10:54:51 -04:00

patch 8.2.4939: matchfuzzypos() with "matchseq" does not have all positions

Problem:    matchfuzzypos() with "matchseq" does not have all positions.
Solution:   Also add a position for white space. (closes #10404)
This commit is contained in:
zeertzjq 2022-05-11 14:15:37 +01:00 committed by Bram Moolenaar
parent a59f2dfd0c
commit 9af2bc0751
4 changed files with 9 additions and 5 deletions

View File

@ -5682,10 +5682,9 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
The optional {dict} argument always supports the following The optional {dict} argument always supports the following
items: items:
matchseq When this item is present and {str} contains matchseq When this item is present return only matches
multiple words separated by white space, then that contain the characters in {str} in the
returns only matches that contain the words in given sequence.
the given sequence.
If {list} is a list of dictionaries, then the optional {dict} If {list} is a list of dictionaries, then the optional {dict}
argument supports the following additional items: argument supports the following additional items:

View File

@ -4729,7 +4729,7 @@ fuzzy_match_in_list(
p = str; p = str;
while (*p != NUL) while (*p != NUL)
{ {
if (!VIM_ISWHITE(PTR2CHAR(p))) if (!VIM_ISWHITE(PTR2CHAR(p)) || matchseq)
{ {
if (list_append_number(items[match_count].lmatchpos, if (list_append_number(items[match_count].lmatchpos,
matches[j]) == FAIL) matches[j]) == FAIL)

View File

@ -126,6 +126,9 @@ func Test_matchfuzzypos()
" match multiple words (separated by space) " match multiple words (separated by space)
call assert_equal([['foo bar baz'], [[8, 9, 10, 0, 1, 2]], [369]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo')) call assert_equal([['foo bar baz'], [[8, 9, 10, 0, 1, 2]], [369]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo'))
call assert_equal([[], [], []], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo', {'matchseq': 1}))
call assert_equal([['foo bar baz'], [[0, 1, 2, 8, 9, 10]], [369]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz'))
call assert_equal([['foo bar baz'], [[0, 1, 2, 3, 4, 5, 10]], [326]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz', {'matchseq': 1}))
call assert_equal([[], [], []], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('one two')) call assert_equal([[], [], []], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('one two'))
call assert_equal([[], [], []], ['foo bar']->matchfuzzypos(" \t ")) call assert_equal([[], [], []], ['foo bar']->matchfuzzypos(" \t "))
call assert_equal([['grace'], [[1, 2, 3, 4, 2, 3, 4, 0, 1, 2, 3, 4]], [657]], ['grace']->matchfuzzypos('race ace grace')) call assert_equal([['grace'], [[1, 2, 3, 4, 2, 3, 4, 0, 1, 2, 3, 4]], [657]], ['grace']->matchfuzzypos('race ace grace'))

View File

@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4939,
/**/ /**/
4938, 4938,
/**/ /**/