@@ -1351,8 +1351,9 @@ do_search(
13511351 pat = p ; /* put pat after search command */
13521352 }
13531353
1354- if ((options & SEARCH_ECHO ) && messaging ()
1355- && !cmd_silent && msg_silent == 0 )
1354+ if ((options & SEARCH_ECHO ) && messaging () &&
1355+ !msg_silent &&
1356+ (!cmd_silent || !shortmess (SHM_SEARCHCOUNT )))
13561357 {
13571358 char_u * trunc ;
13581359 char_u off_buf [40 ];
@@ -1362,7 +1363,8 @@ do_search(
13621363 msg_start ();
13631364
13641365 // Get the offset, so we know how long it is.
1365- if (spats [0 ].off .line || spats [0 ].off .end || spats [0 ].off .off )
1366+ if (!cmd_silent &&
1367+ (spats [0 ].off .line || spats [0 ].off .end || spats [0 ].off .off ))
13661368 {
13671369 p = off_buf ;
13681370 * p ++ = dirc ;
@@ -1383,13 +1385,13 @@ do_search(
13831385 else
13841386 p = searchstr ;
13851387
1386- if (!shortmess (SHM_SEARCHCOUNT ))
1388+ if (!shortmess (SHM_SEARCHCOUNT ) || cmd_silent )
13871389 {
13881390 // Reserve enough space for the search pattern + offset +
13891391 // search stat. Use all the space available, so that the
13901392 // search state is right aligned. If there is not enough space
13911393 // msg_strtrunc() will shorten in the middle.
1392- if (msg_scrolled != 0 )
1394+ if (msg_scrolled != 0 || cmd_silent )
13931395 // Use all the columns.
13941396 len = (int )(Rows - msg_row ) * Columns - 1 ;
13951397 else
@@ -1406,62 +1408,67 @@ do_search(
14061408 if (msgbuf != NULL )
14071409 {
14081410 vim_memset (msgbuf , ' ' , len );
1409- msgbuf [0 ] = dirc ;
14101411 msgbuf [len - 1 ] = NUL ;
1411-
1412- if (enc_utf8 && utf_iscomposing (utf_ptr2char (p )))
1413- {
1414- // Use a space to draw the composing char on.
1415- msgbuf [1 ] = ' ' ;
1416- mch_memmove (msgbuf + 2 , p , STRLEN (p ));
1417- }
1418- else
1419- mch_memmove (msgbuf + 1 , p , STRLEN (p ));
1420- if (off_len > 0 )
1421- mch_memmove (msgbuf + STRLEN (p ) + 1 , off_buf , off_len );
1422-
1423- trunc = msg_strtrunc (msgbuf , TRUE);
1424- if (trunc != NULL )
1412+ // do not fill the msgbuf buffer, if cmd_silent is set, leave it
1413+ // empty for the search_stat feature.
1414+ if (!cmd_silent )
14251415 {
1426- vim_free (msgbuf );
1427- msgbuf = trunc ;
1428- }
1416+ msgbuf [0 ] = dirc ;
14291417
1430- #ifdef FEAT_RIGHTLEFT
1431- // The search pattern could be shown on the right in rightleft
1432- // mode, but the 'ruler' and 'showcmd' area use it too, thus
1433- // it would be blanked out again very soon. Show it on the
1434- // left, but do reverse the text.
1435- if (curwin -> w_p_rl && * curwin -> w_p_rlc == 's' )
1436- {
1437- char_u * r ;
1438- size_t pat_len ;
1418+ if (enc_utf8 && utf_iscomposing (utf_ptr2char (p )))
1419+ {
1420+ // Use a space to draw the composing char on.
1421+ msgbuf [1 ] = ' ' ;
1422+ mch_memmove (msgbuf + 2 , p , STRLEN (p ));
1423+ }
1424+ else
1425+ mch_memmove (msgbuf + 1 , p , STRLEN (p ));
1426+ if (off_len > 0 )
1427+ mch_memmove (msgbuf + STRLEN (p ) + 1 , off_buf , off_len );
14391428
1440- r = reverse_text (msgbuf );
1441- if (r != NULL )
1429+ trunc = msg_strtrunc (msgbuf , TRUE );
1430+ if (trunc != NULL )
14421431 {
14431432 vim_free (msgbuf );
1444- msgbuf = r ;
1445- // move reversed text to beginning of buffer
1446- while (* r != NUL && * r == ' ' )
1447- r ++ ;
1448- pat_len = msgbuf + STRLEN (msgbuf ) - r ;
1449- mch_memmove (msgbuf , r , pat_len );
1450- // overwrite old text
1451- if ((size_t )(r - msgbuf ) >= pat_len )
1452- vim_memset (r , ' ' , pat_len );
1453- else
1454- vim_memset (msgbuf + pat_len , ' ' , r - msgbuf );
1433+ msgbuf = trunc ;
14551434 }
1456- }
1457- #endif
1458- msg_outtrans (msgbuf );
1459- msg_clr_eos ();
1460- msg_check ();
14611435
1462- gotocmdline (FALSE);
1463- out_flush ();
1464- msg_nowait = TRUE; // don't wait for this message
1436+ #ifdef FEAT_RIGHTLEFT
1437+ // The search pattern could be shown on the right in rightleft
1438+ // mode, but the 'ruler' and 'showcmd' area use it too, thus
1439+ // it would be blanked out again very soon. Show it on the
1440+ // left, but do reverse the text.
1441+ if (curwin -> w_p_rl && * curwin -> w_p_rlc == 's' )
1442+ {
1443+ char_u * r ;
1444+ size_t pat_len ;
1445+
1446+ r = reverse_text (msgbuf );
1447+ if (r != NULL )
1448+ {
1449+ vim_free (msgbuf );
1450+ msgbuf = r ;
1451+ // move reversed text to beginning of buffer
1452+ while (* r != NUL && * r == ' ' )
1453+ r ++ ;
1454+ pat_len = msgbuf + STRLEN (msgbuf ) - r ;
1455+ mch_memmove (msgbuf , r , pat_len );
1456+ // overwrite old text
1457+ if ((size_t )(r - msgbuf ) >= pat_len )
1458+ vim_memset (r , ' ' , pat_len );
1459+ else
1460+ vim_memset (msgbuf + pat_len , ' ' , r - msgbuf );
1461+ }
1462+ }
1463+ #endif
1464+ msg_outtrans (msgbuf );
1465+ msg_clr_eos ();
1466+ msg_check ();
1467+
1468+ gotocmdline (FALSE);
1469+ out_flush ();
1470+ msg_nowait = TRUE; // don't wait for this message
1471+ }
14651472 }
14661473 }
14671474
@@ -1569,7 +1576,7 @@ do_search(
15691576 // Show [1/15] if 'S' is not in 'shortmess'.
15701577 if ((options & SEARCH_ECHO )
15711578 && messaging ()
1572- && !( cmd_silent + msg_silent )
1579+ && !msg_silent
15731580 && c != FAIL
15741581 && !shortmess (SHM_SEARCHCOUNT )
15751582 && msgbuf != NULL )
0 commit comments