Mercurial > vim
changeset 26101:5317b0ae4893 v8.2.3583
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Commit: https://github.com/vim/vim/commit/0c71114aede81a209b7efc126b4bf19f11d58955
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Nov 12 10:30:04 2021 +0000
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Problem: The "gd" and "gD" commands do not update search stats. (Gary
Johnson)
Solution: Clear search stats.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 12 Nov 2021 11:45:04 +0100 |
parents | babd9f1dbe12 |
children | eeb8654235f6 |
files | src/normal.c src/testdir/dumps/Test_searchstatgd_1.dump src/testdir/dumps/Test_searchstatgd_2.dump src/testdir/test_search_stat.vim src/version.c |
diffstat | 5 files changed, 59 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -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(); -#endif + 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; + } } /*
new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_searchstatgd_1.dump @@ -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|
new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_searchstatgd_2.dump @@ -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|
--- a/src/testdir/test_search_stat.vim +++ b/src/testdir/test_search_stat.vim @@ -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