diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-11 14:15:37 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-11 14:15:37 +0100 |
commit | 9af2bc075169e14fd06ed967d28eac7206d21f36 (patch) | |
tree | 9c4228bd6f908932676943b448f81b7e76707d0c | |
parent | a59f2dfd0cf9ee1a584d3de5b7c2d47648e79060 (diff) | |
download | vim-git-9af2bc075169e14fd06ed967d28eac7206d21f36.tar.gz |
patch 8.2.4939: matchfuzzypos() with "matchseq" does not have all positionsv8.2.4939
Problem: matchfuzzypos() with "matchseq" does not have all positions.
Solution: Also add a position for white space. (closes #10404)
-rw-r--r-- | runtime/doc/builtin.txt | 7 | ||||
-rw-r--r-- | src/search.c | 2 | ||||
-rw-r--r-- | src/testdir/test_matchfuzzy.vim | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 60fe91f1d..7d62583d6 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -5682,10 +5682,9 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* The optional {dict} argument always supports the following items: - matchseq When this item is present and {str} contains - multiple words separated by white space, then - returns only matches that contain the words in - the given sequence. + matchseq When this item is present return only matches + that contain the characters in {str} in the + given sequence. If {list} is a list of dictionaries, then the optional {dict} argument supports the following additional items: diff --git a/src/search.c b/src/search.c index cd5166f48..353a6eba4 100644 --- a/src/search.c +++ b/src/search.c @@ -4729,7 +4729,7 @@ fuzzy_match_in_list( p = str; while (*p != NUL) { - if (!VIM_ISWHITE(PTR2CHAR(p))) + if (!VIM_ISWHITE(PTR2CHAR(p)) || matchseq) { if (list_append_number(items[match_count].lmatchpos, matches[j]) == FAIL) diff --git a/src/testdir/test_matchfuzzy.vim b/src/testdir/test_matchfuzzy.vim index 8c0477c96..b397392a7 100644 --- a/src/testdir/test_matchfuzzy.vim +++ b/src/testdir/test_matchfuzzy.vim @@ -126,6 +126,9 @@ func Test_matchfuzzypos() " 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', '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']->matchfuzzypos(" \t ")) call assert_equal([['grace'], [[1, 2, 3, 4, 2, 3, 4, 0, 1, 2, 3, 4]], [657]], ['grace']->matchfuzzypos('race ace grace')) diff --git a/src/version.c b/src/version.c index 0a3a5df8b..304adc5f4 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4939, +/**/ 4938, /**/ 4937, |