]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0840: search match count wrong when only match is in fold v8.2.0840
authorBram Moolenaar <Bram@vim.org>
Fri, 29 May 2020 20:49:43 +0000 (22:49 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 29 May 2020 20:49:43 +0000 (22:49 +0200)
Problem:    Search match count wrong when only match is in fold.
Solution:   Update search stats when in a closed fold. (Christian Brabandt,
            closes #6160, closes #6152)

src/search.c
src/testdir/dumps/Test_searchstat_3.dump [new file with mode: 0644]
src/testdir/test_search_stat.vim
src/version.c

index 0bf49629eb206daf8315b4a09bd571a3f3e65827..7bda6f9834176fcc6c7261956806924744f5985c 100644 (file)
@@ -1592,7 +1592,12 @@ do_search(
                && !shortmess(SHM_SEARCHCOUNT)
                && msgbuf != NULL)
            search_stat(dirc, &pos, show_top_bot_msg, msgbuf,
-                                                  (count != 1 || has_offset));
+                       (count != 1 || has_offset
+#ifdef FEAT_FOLDING
+               || (!(fdo_flags & FDO_SEARCH) &&
+                   hasFolding(curwin->w_cursor.lnum, NULL, NULL))
+#endif
+           ));
 
        /*
         * The search command can be followed by a ';' to do another search.
diff --git a/src/testdir/dumps/Test_searchstat_3.dump b/src/testdir/dumps/Test_searchstat_3.dump
new file mode 100644 (file)
index 0000000..a21b47e
--- /dev/null
@@ -0,0 +1,10 @@
+|i+0&#ffffff0|f| @72
+>++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |f|o@1|-@57
+|e+0#0000000#ffffff0|n|d|i|f| @69
+@75
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|/+0#0000000&|f|o@1| @35|[|1|/|2|]| @11|2|,|2|-|1| @8|A|l@1| 
index 9bd2404df0c4f979c5521f1f75609feb43813fe3..68d339fb3b63c932fa1875b42eeafc8b6a3a5acd 100644 (file)
@@ -186,6 +186,35 @@ func Test_search_stat()
   bwipe!
 endfunc
 
+func Test_search_stat_foldopen()
+  CheckScreendump
+
+  let lines =<< trim END
+    set shortmess-=S
+    setl foldenable foldmethod=indent foldopen-=search
+    call append(0, ['if', "\tfoo", "\tfoo", 'endif'])
+    let @/ = 'foo'
+    call cursor(1,1)
+    norm n
+  END
+  call writefile(lines, 'Xsearchstat1')
+
+  let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10})
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_searchstat_3', {})
+
+  call term_sendkeys(buf, "n")
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_searchstat_3', {})
+
+  call term_sendkeys(buf, "n")
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_searchstat_3', {})
+
+  call StopVimInTerminal(buf)
+  call delete('Xsearchstat1')
+endfunc
+
 func! Test_search_stat_screendump()
   CheckScreendump
 
index a1b6a7d8b41c93c3c462c168367cb0013a5c7b76..7c5b3c0371a3c285a8f6468a619801b4496b098f 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    840,
 /**/
     839,
 /**/