aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2019-05-27 16:04:46 +0900
committererw7 <erw7.github@gmail.com>2019-06-05 09:57:25 +0900
commite8ca281d3b9243e66430f7f139c19aabead3de95 (patch)
treed6f4fe0721b34b915bf058b959134fd5615116bb
parent6cee73195fb5d1d081a1e9ea907cc996d97082de (diff)
downloadrneovim-e8ca281d3b9243e66430f7f139c19aabead3de95.tar.gz
rneovim-e8ca281d3b9243e66430f7f139c19aabead3de95.tar.bz2
rneovim-e8ca281d3b9243e66430f7f139c19aabead3de95.zip
vim-patch:8.1.1283: delaying half a second after the top-bot message
Problem: Delaying half a second after the top-bot message. Solution: Instead of the delay add "W" to the search count. https://github.com/vim/vim/commit/c7a10b35de70471519d104a74d402c63557f0512
-rw-r--r--src/nvim/search.c21
-rw-r--r--src/nvim/testdir/test_search_stat.vim5
2 files changed, 20 insertions, 6 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 9756faff33..2a14afd762 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1055,6 +1055,8 @@ int do_search(
* Repeat the search when pattern followed by ';', e.g. "/foo/;?bar".
*/
for (;; ) {
+ bool show_top_bot_msg = false;
+
searchstr = pat;
dircp = NULL;
/* use previous pattern */
@@ -1261,7 +1263,7 @@ int do_search(
if (!shortmess(SHM_SEARCH)
&& ((dirc == '/' && lt(pos, curwin->w_cursor))
|| (dirc == '?' && lt(curwin->w_cursor, pos)))) {
- os_delay(500L, false); // leave some time for top_bot_msg
+ show_top_bot_msg = true;
}
if (c == FAIL) {
@@ -1312,7 +1314,7 @@ int do_search(
&& c != FAIL
&& !shortmess(SHM_SEARCHCOUNT)
&& msgbuf != NULL) {
- search_stat(dirc, &pos, msgbuf);
+ search_stat(dirc, &pos, show_top_bot_msg, msgbuf);
}
// The search command can be followed by a ';' to do another search.
@@ -4196,7 +4198,8 @@ int linewhite(linenr_T lnum)
}
// Add the search count "[3/19]" to "msgbuf".
-static void search_stat(int dirc, pos_T *pos, char_u *msgbuf)
+static void search_stat(int dirc, pos_T *pos,
+ bool show_top_bot_msg, char_u *msgbuf)
{
int save_ws = p_ws;
int wraparound = false;
@@ -4256,8 +4259,9 @@ static void search_stat(int dirc, pos_T *pos, char_u *msgbuf)
}
}
if (cur > 0) {
-#define STAT_BUF_LEN 10
+#define STAT_BUF_LEN 12
char t[STAT_BUF_LEN] = "";
+ int len;
if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {
if (cur == OUT_OF_TIME) {
@@ -4280,7 +4284,14 @@ static void search_stat(int dirc, pos_T *pos, char_u *msgbuf)
vim_snprintf(t, STAT_BUF_LEN, "[%d/%d]", cur, cnt);
}
}
- memmove(msgbuf + STRLEN(msgbuf) - STRLEN(t), t, STRLEN(t));
+
+ len = STRLEN(t);
+ if (show_top_bot_msg && len + 3 < STAT_BUF_LEN) {
+ STRCPY(t + len, " W");
+ len += 2;
+ }
+
+ memmove(msgbuf + STRLEN(msgbuf) - len, t, len);
if (dirc == '?' && cur == 100) {
cur = -1;
}
diff --git a/src/nvim/testdir/test_search_stat.vim b/src/nvim/testdir/test_search_stat.vim
index 37e2fdaef5..57dad81b81 100644
--- a/src/nvim/testdir/test_search_stat.vim
+++ b/src/nvim/testdir/test_search_stat.vim
@@ -3,6 +3,8 @@
" This test is fragile, it might not work interactively, but it works when run
" as test!
+source shared.vim
+
func! Test_search_stat()
new
set shortmess-=S
@@ -79,7 +81,7 @@ func! Test_search_stat()
set norl
endif
- " 9) normal, back at top
+ " 9) normal, back at bottom
call cursor(1,1)
let @/ = 'foobar'
let pat = '?foobar\s\+'
@@ -87,6 +89,7 @@ func! Test_search_stat()
let stat = '\[20/20\]'
call assert_match(pat .. stat, g:a)
call assert_match('search hit TOP, continuing at BOTTOM', g:a)
+ call assert_match('\[20/20\] W', Screenline(&lines))
" 10) normal, no match
call cursor(1,1)