]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4939: matchfuzzypos() with "matchseq" does not have all positions v8.2.4939
authorzeertzjq <zeertzjq@outlook.com>
Wed, 11 May 2022 13:15:37 +0000 (14:15 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 11 May 2022 13:15:37 +0000 (14:15 +0100)
Problem:    matchfuzzypos() with "matchseq" does not have all positions.
Solution:   Also add a position for white space. (closes #10404)

runtime/doc/builtin.txt
src/search.c
src/testdir/test_matchfuzzy.vim
src/version.c

index 60fe91f1d1e2108ca3a6e2c5c080028b5cd6cf5d..7d62583d62cdf5f15d655b7e29aab114cfdffd22 100644 (file)
@@ -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:
index cd5166f4836d4c682c2cac2047603730123b819d..353a6eba403291eebec32737afd21734f7767e55 100644 (file)
@@ -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)
index 8c0477c9635c3b517431e3b0bcdd25473f1c3739..b397392a763b9d5590eeeccf6d15899f113b8251 100644 (file)
@@ -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'))
index 0a3a5df8bc97e10ad96892a136ce587027ba6530..304adc5f4159bfb47ad560567b61c3fea62e7126 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4939,
 /**/
     4938,
 /**/