aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-05-11 21:51:31 +0800
committerGitHub <noreply@github.com>2022-05-11 21:51:31 +0800
commite36e0f7b2fde4f28c2e5d1a929c2464029668c86 (patch)
tree7ab4cf3fb43cffd7dbd2a5c406ede562d3471167
parentb13089c9569e8c61d644c2e50eee747aa2fbb9ef (diff)
downloadrneovim-e36e0f7b2fde4f28c2e5d1a929c2464029668c86.tar.gz
rneovim-e36e0f7b2fde4f28c2e5d1a929c2464029668c86.tar.bz2
rneovim-e36e0f7b2fde4f28c2e5d1a929c2464029668c86.zip
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) https://github.com/vim/vim/commit/9af2bc075169e14fd06ed967d28eac7206d21f36
-rw-r--r--runtime/doc/builtin.txt7
-rw-r--r--src/nvim/search.c2
-rw-r--r--src/nvim/testdir/test_matchfuzzy.vim3
3 files changed, 7 insertions, 5 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 67989cb49f..3f0d0770bf 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -4976,10 +4976,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/nvim/search.c b/src/nvim/search.c
index bee17e861a..9143632c64 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -5160,7 +5160,7 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
int j = 0;
const char_u *p = str;
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]);
j++;
}
diff --git a/src/nvim/testdir/test_matchfuzzy.vim b/src/nvim/testdir/test_matchfuzzy.vim
index d53f8b0f4d..533aec8d9a 100644
--- a/src/nvim/testdir/test_matchfuzzy.vim
+++ b/src/nvim/testdir/test_matchfuzzy.vim
@@ -135,6 +135,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'))