]> granicus.if.org Git - vim/commitdiff
patch 8.2.3583: the "gd" and "gD" commands do not update search stats v8.2.3583
authorBram Moolenaar <Bram@vim.org>
Fri, 12 Nov 2021 10:30:04 +0000 (10:30 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 12 Nov 2021 10:30:04 +0000 (10:30 +0000)
Problem:    The "gd" and "gD" commands do not update search stats. (Gary
            Johnson)
Solution:   Clear search stats.

src/normal.c
src/testdir/dumps/Test_searchstatgd_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_searchstatgd_2.dump [new file with mode: 0644]
src/testdir/test_search_stat.vim
src/version.c

index ba3b53b64ac5e553696a7f79179df4efcf0ecf74..11b61f92a6cf9644d0a2c318e79d0777605c4688 100644 (file)
@@ -2305,12 +2305,20 @@ nv_gd(
 
     if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0
            || find_decl(ptr, len, nchar == 'd', thisblock, SEARCH_START)
-                                                                     == FAIL)
+                                                                      == FAIL)
+    {
        clearopbeep(oap);
+    }
+    else
+    {
 #ifdef FEAT_FOLDING
-    else if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
-       foldOpenCursor();
+       if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
+           foldOpenCursor();
 #endif
+       // clear any search statistics
+       if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT))
+           clear_cmdline = TRUE;
+    }
 }
 
 /*
diff --git a/src/testdir/dumps/Test_searchstatgd_1.dump b/src/testdir/dumps/Test_searchstatgd_1.dump
new file mode 100644 (file)
index 0000000..672af91
--- /dev/null
@@ -0,0 +1,10 @@
+|i+0&#ffffff0|n|t| |c|a|t|;| @66
+|i|n|t| >d+0&#ffff4012|o|g|;+0&#ffffff0| @66
+|c|a|t| |=| |d+0&#ffff4012|o|g|;+0&#ffffff0| @64
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|/+0#0000000&|d|o|g| @35|[|1|/|2|]| @11|2|,|5| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_searchstatgd_2.dump b/src/testdir/dumps/Test_searchstatgd_2.dump
new file mode 100644 (file)
index 0000000..ea1ac4d
--- /dev/null
@@ -0,0 +1,10 @@
+|i+0&#ffffff0|n|t| >c+0&#ffff4012|a|t|;+0&#ffffff0| @66
+|i|n|t| |d|o|g|;| @66
+|c+0&#ffff4012|a|t| +0&#ffffff0|=| |d|o|g|;| @64
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|5| @10|A|l@1| 
index 2afccef5d16005011b9585e9f8fb033ebf8c130b..68fcc4911fa3871d9c715705ced0338db8a09a5f 100644 (file)
@@ -355,4 +355,29 @@ func! Test_search_stat_screendump()
   call delete('Xsearchstat')
 endfunc
 
+func Test_search_stat_then_gd()
+  CheckScreendump
+
+  let lines =<< trim END
+    call setline(1, ['int cat;', 'int dog;', 'cat = dog;'])
+    set shortmess-=S
+    set hlsearch
+  END
+  call writefile(lines, 'Xsearchstatgd')
+
+  let buf = RunVimInTerminal('-S Xsearchstatgd', #{rows: 10})
+  call term_sendkeys(buf, "/dog\<CR>")
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_searchstatgd_1', {})
+
+  call term_sendkeys(buf, "G0gD")
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_searchstatgd_2', {})
+
+  call StopVimInTerminal(buf)
+  call delete('Xsearchstatgd')
+endfunc
+
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index 73ba32ef24965042de40cb8d7bcd6304641a7548..713b5e78d362b9565679caecf29e744538969af7 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3583,
 /**/
     3582,
 /**/