]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0838: searchcount() returns wrong cached maxcount master v9.2.0838
authorglepnir <glephunter@gmail.com>
Wed, 22 Jul 2026 20:08:06 +0000 (20:08 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 22 Jul 2026 20:08:06 +0000 (20:08 +0000)
Problem:  Cached searchcount() returns 'maxsearchcount' instead of the
          requested maxcount.
Solution: return the remembered last_maxcount (glepnir)

closes: #20701

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/search.c
src/testdir/test_search.vim
src/version.c

index bcf168be02e64045c9b1bda3bab949b15d04be66..4f3a5dd9efaabd8cad74591271ca5937dc97b75c 100644 (file)
@@ -3309,7 +3309,7 @@ update_search_stat(
        stat->cnt = cnt;
        stat->exact_match = exact_match;
        stat->incomplete = incomplete;
-       stat->last_maxcount = p_msc;
+       stat->last_maxcount = last_maxcount;
        return;
     }
     last_maxcount = maxcount;
index be0a460b71e08736c1f0b5c00edea3f1b7e4d2b8..82c706132f94d185013d367601f85c69181f9c4b 100644 (file)
@@ -2457,4 +2457,17 @@ func Test_incsearch_delimiter_ctrlg()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_searchcount_maxcount_cached()
+  new
+  call setline(1, repeat(['foo'], 5))
+  set maxsearchcount=99
+  let @/ = 'foo'
+  call cursor(1, 1)
+  call searchcount(#{recompute: v:true,  maxcount: 3})
+  let r = searchcount(#{recompute: v:false, maxcount: 3})
+  call assert_equal(3, r.maxcount)
+  set maxsearchcount&
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index d463a17d81673d8d3cad83479cd98b065e998b7f..07772b03f5b807a0f2689c958037ebb8436ebe46 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    838,
 /**/
     837,
 /**/