]> granicus.if.org Git - vim/commitdiff
patch 8.1.1283: delaying half a second after the top-bot message v8.1.1283
authorBram Moolenaar <Bram@vim.org>
Mon, 6 May 2019 19:37:18 +0000 (21:37 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 6 May 2019 19:37:18 +0000 (21:37 +0200)
Problem:    Delaying half a second after the top-bot message.
Solution:   Instead of the delay add "W" to the search count.

src/search.c
src/testdir/test_search_stat.vim
src/version.c

index 1fa52b443cfddb22a4b6f31284774774a25e281e..dd5519e79283969a706f55fe0f5b7d4d8c64bcff 100644 (file)
@@ -26,7 +26,7 @@ static void show_pat_in_path(char_u *, int,
 #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
@@ -1294,6 +1294,8 @@ do_search(
      */
     for (;;)
     {
+       int     show_top_bot_msg = FALSE;
+
        searchstr = pat;
        dircp = NULL;
                                            /* use previous pattern */
@@ -1524,7 +1526,7 @@ do_search(
        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)
        {
@@ -1581,7 +1583,7 @@ 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.
@@ -4911,6 +4913,7 @@ linewhite(linenr_T lnum)
 search_stat(
     int            dirc,
     pos_T   *pos,
+    int            show_top_bot_msg,
     char_u  *msgbuf)
 {
     int                    save_ws = p_ws;
@@ -4979,8 +4982,9 @@ search_stat(
     }
     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')
@@ -5006,7 +5010,15 @@ search_stat(
            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;
 
index 37e2fdaef5842ec16f3924036fa1769479cd5d8a..57dad81b8162a1f3ddd9b6b917dbe8f6e57904ea 100644 (file)
@@ -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)
index 90b6904f2e333fc7f5f371f88dee0fb92cefbfb5..892d1a50754313b607de05745594813a91ec05ba 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1283,
 /**/
     1282,
 /**/