comparison src/search.c @ 17938:1e86f8b18a5d v8.1.1965

patch 8.1.1965: search count message is not displayed when using a mapping Commit: https://github.com/vim/vim/commit/359ad1a6f92d0d3b4b942ea003fb02dc57bbfc9e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 2 21:44:59 2019 +0200 patch 8.1.1965: search count message is not displayed when using a mapping Problem: The search count message is not displayed when using a mapping. (Gary Johnson) Solution: Ignore cmd_silent for showing the search count. (Christian Brabandt)
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Sep 2019 22:00:03 +0200
parents 59f8948b7590
children c77a41ea0365
comparison
equal deleted inserted replaced
17937:846f904817c0 17938:1e86f8b18a5d
1349 searchcmdlen += (int)(p - pat); 1349 searchcmdlen += (int)(p - pat);
1350 1350
1351 pat = p; /* put pat after search command */ 1351 pat = p; /* put pat after search command */
1352 } 1352 }
1353 1353
1354 if ((options & SEARCH_ECHO) && messaging() 1354 if ((options & SEARCH_ECHO) && messaging() &&
1355 && !cmd_silent && msg_silent == 0) 1355 !msg_silent &&
1356 (!cmd_silent || !shortmess(SHM_SEARCHCOUNT)))
1356 { 1357 {
1357 char_u *trunc; 1358 char_u *trunc;
1358 char_u off_buf[40]; 1359 char_u off_buf[40];
1359 size_t off_len = 0; 1360 size_t off_len = 0;
1360 1361
1361 // Compute msg_row early. 1362 // Compute msg_row early.
1362 msg_start(); 1363 msg_start();
1363 1364
1364 // Get the offset, so we know how long it is. 1365 // 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))
1366 { 1368 {
1367 p = off_buf; 1369 p = off_buf;
1368 *p++ = dirc; 1370 *p++ = dirc;
1369 if (spats[0].off.end) 1371 if (spats[0].off.end)
1370 *p++ = 'e'; 1372 *p++ = 'e';
1381 if (*searchstr == NUL) 1383 if (*searchstr == NUL)
1382 p = spats[0].pat; 1384 p = spats[0].pat;
1383 else 1385 else
1384 p = searchstr; 1386 p = searchstr;
1385 1387
1386 if (!shortmess(SHM_SEARCHCOUNT)) 1388 if (!shortmess(SHM_SEARCHCOUNT) || cmd_silent)
1387 { 1389 {
1388 // Reserve enough space for the search pattern + offset + 1390 // Reserve enough space for the search pattern + offset +
1389 // search stat. Use all the space available, so that the 1391 // search stat. Use all the space available, so that the
1390 // search state is right aligned. If there is not enough space 1392 // search state is right aligned. If there is not enough space
1391 // msg_strtrunc() will shorten in the middle. 1393 // msg_strtrunc() will shorten in the middle.
1392 if (msg_scrolled != 0) 1394 if (msg_scrolled != 0 || cmd_silent)
1393 // Use all the columns. 1395 // Use all the columns.
1394 len = (int)(Rows - msg_row) * Columns - 1; 1396 len = (int)(Rows - msg_row) * Columns - 1;
1395 else 1397 else
1396 // Use up to 'showcmd' column. 1398 // Use up to 'showcmd' column.
1397 len = (int)(Rows - msg_row - 1) * Columns + sc_col - 1; 1399 len = (int)(Rows - msg_row - 1) * Columns + sc_col - 1;
1404 1406
1405 msgbuf = alloc(len); 1407 msgbuf = alloc(len);
1406 if (msgbuf != NULL) 1408 if (msgbuf != NULL)
1407 { 1409 {
1408 vim_memset(msgbuf, ' ', len); 1410 vim_memset(msgbuf, ' ', len);
1409 msgbuf[0] = dirc;
1410 msgbuf[len - 1] = NUL; 1411 msgbuf[len - 1] = NUL;
1411 1412 // do not fill the msgbuf buffer, if cmd_silent is set, leave it
1412 if (enc_utf8 && utf_iscomposing(utf_ptr2char(p))) 1413 // empty for the search_stat feature.
1414 if (!cmd_silent)
1413 { 1415 {
1414 // Use a space to draw the composing char on. 1416 msgbuf[0] = dirc;
1415 msgbuf[1] = ' '; 1417
1416 mch_memmove(msgbuf + 2, p, STRLEN(p)); 1418 if (enc_utf8 && utf_iscomposing(utf_ptr2char(p)))
1417 } 1419 {
1418 else 1420 // Use a space to draw the composing char on.
1419 mch_memmove(msgbuf + 1, p, STRLEN(p)); 1421 msgbuf[1] = ' ';
1420 if (off_len > 0) 1422 mch_memmove(msgbuf + 2, p, STRLEN(p));
1421 mch_memmove(msgbuf + STRLEN(p) + 1, off_buf, off_len); 1423 }
1422 1424 else
1423 trunc = msg_strtrunc(msgbuf, TRUE); 1425 mch_memmove(msgbuf + 1, p, STRLEN(p));
1424 if (trunc != NULL) 1426 if (off_len > 0)
1425 { 1427 mch_memmove(msgbuf + STRLEN(p) + 1, off_buf, off_len);
1426 vim_free(msgbuf); 1428
1427 msgbuf = trunc; 1429 trunc = msg_strtrunc(msgbuf, TRUE);
1428 } 1430 if (trunc != NULL)
1429
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;
1439
1440 r = reverse_text(msgbuf);
1441 if (r != NULL)
1442 { 1431 {
1443 vim_free(msgbuf); 1432 vim_free(msgbuf);
1444 msgbuf = r; 1433 msgbuf = trunc;
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);
1455 } 1434 }
1435
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
1456 } 1471 }
1457 #endif
1458 msg_outtrans(msgbuf);
1459 msg_clr_eos();
1460 msg_check();
1461
1462 gotocmdline(FALSE);
1463 out_flush();
1464 msg_nowait = TRUE; // don't wait for this message
1465 } 1472 }
1466 } 1473 }
1467 1474
1468 /* 1475 /*
1469 * If there is a character offset, subtract it from the current 1476 * If there is a character offset, subtract it from the current
1567 } 1574 }
1568 1575
1569 // Show [1/15] if 'S' is not in 'shortmess'. 1576 // Show [1/15] if 'S' is not in 'shortmess'.
1570 if ((options & SEARCH_ECHO) 1577 if ((options & SEARCH_ECHO)
1571 && messaging() 1578 && messaging()
1572 && !(cmd_silent + msg_silent) 1579 && !msg_silent
1573 && c != FAIL 1580 && c != FAIL
1574 && !shortmess(SHM_SEARCHCOUNT) 1581 && !shortmess(SHM_SEARCHCOUNT)
1575 && msgbuf != NULL) 1582 && msgbuf != NULL)
1576 search_stat(dirc, &pos, show_top_bot_msg, msgbuf, 1583 search_stat(dirc, &pos, show_top_bot_msg, msgbuf,
1577 (count != 1 || has_offset)); 1584 (count != 1 || has_offset));