]> granicus.if.org Git - vim/commitdiff
patch 8.2.0887: searchcount().exact_match is 1 right after a match v8.2.0887
authorBram Moolenaar <Bram@vim.org>
Tue, 2 Jun 2020 20:06:21 +0000 (22:06 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 2 Jun 2020 20:06:21 +0000 (22:06 +0200)
Problem:    Searchcount().exact_match is 1 right after a match.
Solution:   Use LT_POS() instead of LTOREQ_POS(). (closes #6189)

src/search.c
src/testdir/test_search_stat.vim
src/version.c

index 0c253e97174e846644e140df309ea9187946cfac..210806258f50d40c8d0a65ddaf8c94fe2648f5a2 100644 (file)
@@ -3252,7 +3252,7 @@ update_search_stat(
            if (LTOREQ_POS(lastpos, p))
            {
                cur = cnt;
-               if (LTOREQ_POS(p, endpos))
+               if (LT_POS(p, endpos))
                    exact_match = TRUE;
            }
            fast_breakcheck();
index de73051d2c7d15cbc93e7bc446451bd525a8291c..668545c5a7a9090e310300328934346b63cdcd8a 100644 (file)
@@ -27,6 +27,14 @@ func Test_search_stat()
   call assert_equal(
     \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99},
     \ searchcount(#{pattern: 'fooooobar', pos: [3, 1, 0]}))
+  " on last char of match
+  call assert_equal(
+    \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99},
+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 9, 0]}))
+  " on char after match
+  call assert_equal(
+    \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},
+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 10, 0]}))
   call assert_equal(
     \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},
     \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0]}))
index 9a34111d66fe36b139d14ae3d33c36678ae37f67..91d4a467ba9a066edff5047a0826c798f40d114d 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    887,
 /**/
     886,
 /**/