summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2023-05-06 19:20:20 +0100
committerBram Moolenaar <Bram@vim.org>2023-05-06 19:20:20 +0100
commit34a6a3617b5b6ce11372439f14762caddc4b0cea (patch)
treeb3b012ab463ed4c20c94285c03983503aebd85e3
parent00d07e7682d289c3afee9df557ae909b9b403f9c (diff)
downloadvim-git-34a6a3617b5b6ce11372439f14762caddc4b0cea.tar.gz
patch 9.0.1518: search stats not always visible when searching backwardsv9.0.1518
Problem: Search stats not always visible when searching backwards. Solution: Do not display the top/bot message on top of the search stats. (Christian Brabandt, closes #12322, closes #12222)
-rw-r--r--src/option.h2
-rw-r--r--src/search.c12
-rw-r--r--src/testdir/dumps/Test_searchstat_back_1.dump10
-rw-r--r--src/testdir/dumps/Test_searchstat_back_2.dump10
-rw-r--r--src/testdir/dumps/Test_searchstat_back_3.dump10
-rw-r--r--src/testdir/test_search_stat.vim30
-rw-r--r--src/version.c2
7 files changed, 70 insertions, 6 deletions
diff --git a/src/option.h b/src/option.h
index 487d87c31..1dc9d51f8 100644
--- a/src/option.h
+++ b/src/option.h
@@ -268,7 +268,7 @@ typedef enum {
#define SHM_COMPLETIONSCAN 'C' // completion scanning messages
#define SHM_RECORDING 'q' // short recording message
#define SHM_FILEINFO 'F' // no file info messages
-#define SHM_SEARCHCOUNT 'S' // search stats: '[1/10]'
+#define SHM_SEARCHCOUNT 'S' // no search stats: '[1/10]'
#define SHM_POSIX "AS" // POSIX value
#define SHM_ALL "rmfixlnwaWtToOsAIcCqFS" // all possible flags for 'shm'
#define SHM_LEN 30 // max length of all flags together
diff --git a/src/search.c b/src/search.c
index 5e3857078..793e04234 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1089,7 +1089,9 @@ searchit(
/*
* If 'wrapscan' is set we continue at the other end of the file.
- * If 'shortmess' does not contain 's', we give a message.
+ * If 'shortmess' does not contain 's', we give a message, but
+ * only, if we won't show the search stat later anyhow,
+ * (so SEARCH_COUNT must be absent).
* This message is also remembered in keep_msg for when the screen
* is redrawn. The keep_msg is cleared whenever another message is
* written.
@@ -1098,7 +1100,9 @@ searchit(
lnum = buf->b_ml.ml_line_count;
else
lnum = 1;
- if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))
+ if (!shortmess(SHM_SEARCH)
+ && shortmess(SHM_SEARCHCOUNT)
+ && (options & SEARCH_MSG))
give_warning((char_u *)_(dir == BACKWARD
? top_bot_msg : bot_top_msg), TRUE);
if (extra_arg != NULL)
@@ -3237,8 +3241,10 @@ update_search_stat(
lbuf = curbuf;
}
+ // when searching backwards and having jumped to the first occurrence,
+ // cur must remain greater than 1
if (EQUAL_POS(lastpos, *cursor_pos) && !wraparound
- && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0))
+ && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 1))
cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;
else
{
diff --git a/src/testdir/dumps/Test_searchstat_back_1.dump b/src/testdir/dumps/Test_searchstat_back_1.dump
new file mode 100644
index 000000000..4b2808b97
--- /dev/null
+++ b/src/testdir/dumps/Test_searchstat_back_1.dump
@@ -0,0 +1,10 @@
+>t+0&#ffffff0|e|s|t| @70
+@75
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|/+0#0000000&|\|<|t|e|s|t|\|>| @30|[|1|/|1|]| @11|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_searchstat_back_2.dump b/src/testdir/dumps/Test_searchstat_back_2.dump
new file mode 100644
index 000000000..b3c44b092
--- /dev/null
+++ b/src/testdir/dumps/Test_searchstat_back_2.dump
@@ -0,0 +1,10 @@
+>t+0&#ffffff0|e|s|t| @70
+@75
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|?+0#0000000&|\|<|t|e|s|t|\|>| @30|[|1|/|1|]| @11|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_searchstat_back_3.dump b/src/testdir/dumps/Test_searchstat_back_3.dump
new file mode 100644
index 000000000..ddc3b3d7e
--- /dev/null
+++ b/src/testdir/dumps/Test_searchstat_back_3.dump
@@ -0,0 +1,10 @@
+>t+0&#ffffff0|e|s|t| @70
+@75
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|s+0#e000002&|e|a|r|c|h| |h|i|t| |T|O|P|,| |c|o|n|t|i|n|u|i|n|g| |a|t| |B|O|T@1|O|M| +0#0000000&@20|1|,|1| @10|A|l@1|
diff --git a/src/testdir/test_search_stat.vim b/src/testdir/test_search_stat.vim
index e205df574..b57b7ba7b 100644
--- a/src/testdir/test_search_stat.vim
+++ b/src/testdir/test_search_stat.vim
@@ -153,7 +153,6 @@ func Test_search_stat()
let g:a = execute(':unsilent :norm! n')
let stat = 'W \[20/1\]'
call assert_match(pat .. stat, g:a)
- call assert_match('search hit BOTTOM, continuing at TOP', g:a)
set norl
endif
@@ -164,7 +163,6 @@ func Test_search_stat()
let g:a = execute(':unsilent :norm! N')
let stat = 'W \[20/20\]'
call assert_match(pat .. stat, g:a)
- call assert_match('search hit TOP, continuing at BOTTOM', g:a)
call assert_match('W \[20/20\]', Screenline(&lines))
" normal, no match
@@ -432,5 +430,33 @@ func Test_search_stat_and_incsearch()
call StopVimInTerminal(buf)
endfunc
+func Test_search_stat_backwards()
+ CheckScreendump
+
+ let lines =<< trim END
+ set shm-=S
+ call setline(1, ['test', ''])
+ END
+ call writefile(lines, 'Xsearchstat_back', 'D')
+
+ let buf = RunVimInTerminal('-S Xsearchstat_back', #{rows: 10})
+ call term_sendkeys(buf, "*")
+ call TermWait(buf)
+ call VerifyScreenDump(buf, 'Test_searchstat_back_1', {})
+
+ call term_sendkeys(buf, "N")
+ call TermWait(buf)
+ call VerifyScreenDump(buf, 'Test_searchstat_back_2', {})
+
+ call term_sendkeys(buf, ":set shm+=S\<cr>N")
+ call TermWait(buf)
+ " shows "Search Hit Bottom.."
+ call VerifyScreenDump(buf, 'Test_searchstat_back_3', {})
+
+ call term_sendkeys(buf, "\<esc>:qa\<cr>")
+ call TermWait(buf)
+
+ call StopVimInTerminal(buf)
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index dc17976de..cf3532434 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1518,
+/**/
1517,
/**/
1516,