mirror of
https://github.com/neovim/neovim.git
synced 2025-10-18 07:41:51 +00:00
vim-patch:8.2.4939: matchfuzzypos() with "matchseq" does not have all positions (#18525)
Problem: matchfuzzypos() with "matchseq" does not have all positions.
Solution: Also add a position for white space. (closes vim/vim#10404)
9af2bc0751
This commit is contained in:
@@ -4976,10 +4976,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:
|
||||||
|
@@ -5160,7 +5160,7 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
const char_u *p = str;
|
const char_u *p = str;
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
if (!ascii_iswhite(utf_ptr2char((char *)p))) {
|
if (!ascii_iswhite(utf_ptr2char((char *)p)) || matchseq) {
|
||||||
tv_list_append_number(items[match_count].lmatchpos, matches[j]);
|
tv_list_append_number(items[match_count].lmatchpos, matches[j]);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
@@ -135,6 +135,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'))
|
||||||
|
Reference in New Issue
Block a user