#ifdef FEAT_VIMINFO
static void wvsp_one(FILE *fp, int idx, char *s, int sc);
#endif
-static void search_stat(int dirc, pos_T *pos, char_u *msgbuf);
+static void search_stat(int dirc, pos_T *pos, int show_top_bot_msg, char_u *msgbuf);
/*
* This file contains various searching-related routines. These fall into
*/
for (;;)
{
+ int show_top_bot_msg = FALSE;
+
searchstr = pat;
dircp = NULL;
/* use previous pattern */
if (!shortmess(SHM_SEARCH)
&& ((dirc == '/' && LT_POS(pos, curwin->w_cursor))
|| (dirc == '?' && LT_POS(curwin->w_cursor, pos))))
- ui_delay(500L, FALSE); // leave some time for top_bot_msg
+ show_top_bot_msg = TRUE;
if (c == FAIL)
{
&& 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.
search_stat(
int dirc,
pos_T *pos,
+ int show_top_bot_msg,
char_u *msgbuf)
{
int save_ws = p_ws;
}
if (cur > 0)
{
-#define STAT_BUF_LEN 10
+#define STAT_BUF_LEN 12
char t[STAT_BUF_LEN] = "";
+ int len;
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl && *curwin->w_p_rlc == 's')
else
vim_snprintf(t, STAT_BUF_LEN, "[%d/%d]", cur, cnt);
}
- mch_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;
+ }
+
+ mch_memmove(msgbuf + STRLEN(msgbuf) - len, t, len);
if (dirc == '?' && cur == 100)
cur = -1;
" 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
set norl
endif
- " 9) normal, back at top
+ " 9) normal, back at bottom
call cursor(1,1)
let @/ = 'foobar'
let pat = '?foobar\s\+'
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)