mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #13012 from janlazo/vim-8.1.1965
vim-patch:8.1.{1965,1970,1980,1992},8.2.0840
This commit is contained in:
commit
d0d1f0f9a6
@ -1155,8 +1155,8 @@ int do_search(
|
|||||||
pat = p; /* put pat after search command */
|
pat = p; /* put pat after search command */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((options & SEARCH_ECHO) && messaging()
|
if ((options & SEARCH_ECHO) && messaging() && !msg_silent
|
||||||
&& !cmd_silent && msg_silent == 0) {
|
&& (!cmd_silent || !shortmess(SHM_SEARCHCOUNT))) {
|
||||||
char_u *trunc;
|
char_u *trunc;
|
||||||
char_u off_buf[40];
|
char_u off_buf[40];
|
||||||
size_t off_len = 0;
|
size_t off_len = 0;
|
||||||
@ -1165,7 +1165,8 @@ int do_search(
|
|||||||
msg_start();
|
msg_start();
|
||||||
|
|
||||||
// Get the offset, so we know how long it is.
|
// Get the offset, so we know how long it is.
|
||||||
if (spats[0].off.line || spats[0].off.end || spats[0].off.off) {
|
if (!cmd_silent
|
||||||
|
&& (spats[0].off.line || spats[0].off.end || spats[0].off.off)) {
|
||||||
p = off_buf; // -V507
|
p = off_buf; // -V507
|
||||||
*p++ = dirc;
|
*p++ = dirc;
|
||||||
if (spats[0].off.end) {
|
if (spats[0].off.end) {
|
||||||
@ -1190,14 +1191,14 @@ int do_search(
|
|||||||
p = searchstr;
|
p = searchstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shortmess(SHM_SEARCHCOUNT)) {
|
if (!shortmess(SHM_SEARCHCOUNT) || cmd_silent) {
|
||||||
// Reserve enough space for the search pattern + offset +
|
// Reserve enough space for the search pattern + offset +
|
||||||
// search stat. Use all the space available, so that the
|
// search stat. Use all the space available, so that the
|
||||||
// search state is right aligned. If there is not enough space
|
// search state is right aligned. If there is not enough space
|
||||||
// msg_strtrunc() will shorten in the middle.
|
// msg_strtrunc() will shorten in the middle.
|
||||||
if (ui_has(kUIMessages)) {
|
if (ui_has(kUIMessages)) {
|
||||||
len = 0; // adjusted below
|
len = 0; // adjusted below
|
||||||
} else if (msg_scrolled != 0) {
|
} else if (msg_scrolled != 0 && !cmd_silent) {
|
||||||
// Use all the columns.
|
// Use all the columns.
|
||||||
len = (Rows - msg_row) * Columns - 1;
|
len = (Rows - msg_row) * Columns - 1;
|
||||||
} else {
|
} else {
|
||||||
@ -1214,11 +1215,13 @@ int do_search(
|
|||||||
|
|
||||||
xfree(msgbuf);
|
xfree(msgbuf);
|
||||||
msgbuf = xmalloc(len);
|
msgbuf = xmalloc(len);
|
||||||
{
|
|
||||||
memset(msgbuf, ' ', len);
|
memset(msgbuf, ' ', len);
|
||||||
msgbuf[0] = dirc;
|
|
||||||
msgbuf[len - 1] = NUL;
|
msgbuf[len - 1] = NUL;
|
||||||
|
|
||||||
|
// do not fill the msgbuf buffer, if cmd_silent is set, leave it
|
||||||
|
// empty for the search_stat feature.
|
||||||
|
if (!cmd_silent) {
|
||||||
|
msgbuf[0] = dirc;
|
||||||
if (utf_iscomposing(utf_ptr2char(p))) {
|
if (utf_iscomposing(utf_ptr2char(p))) {
|
||||||
// Use a space to draw the composing char on.
|
// Use a space to draw the composing char on.
|
||||||
msgbuf[1] = ' ';
|
msgbuf[1] = ' ';
|
||||||
@ -1362,12 +1365,15 @@ int do_search(
|
|||||||
// Show [1/15] if 'S' is not in 'shortmess'.
|
// Show [1/15] if 'S' is not in 'shortmess'.
|
||||||
if ((options & SEARCH_ECHO)
|
if ((options & SEARCH_ECHO)
|
||||||
&& messaging()
|
&& messaging()
|
||||||
&& !(cmd_silent + msg_silent)
|
&& !msg_silent
|
||||||
&& c != FAIL
|
&& c != FAIL
|
||||||
&& !shortmess(SHM_SEARCHCOUNT)
|
&& !shortmess(SHM_SEARCHCOUNT)
|
||||||
&& msgbuf != NULL) {
|
&& msgbuf != NULL) {
|
||||||
search_stat(dirc, &pos, show_top_bot_msg, msgbuf,
|
search_stat(dirc, &pos, show_top_bot_msg, msgbuf,
|
||||||
(count != 1 || has_offset));
|
(count != 1
|
||||||
|
|| has_offset
|
||||||
|
|| (!(fdo_flags & FDO_SEARCH)
|
||||||
|
&& hasFolding(curwin->w_cursor.lnum, NULL, NULL))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// The search command can be followed by a ';' to do another search.
|
// The search command can be followed by a ';' to do another search.
|
||||||
@ -4356,7 +4362,9 @@ static void search_stat(int dirc, pos_T *pos,
|
|||||||
|
|
||||||
len = STRLEN(t);
|
len = STRLEN(t);
|
||||||
if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {
|
if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {
|
||||||
STRCPY(t + len, " W");
|
memmove(t + 2, t, len);
|
||||||
|
t[0] = 'W';
|
||||||
|
t[1] = ' ';
|
||||||
len += 2;
|
len += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
" Tests for search_stats, when "S" is not in 'shortmess'
|
" Tests for search_stats, when "S" is not in 'shortmess'
|
||||||
"
|
|
||||||
" This test is fragile, it might not work interactively, but it works when run
|
|
||||||
" as test!
|
|
||||||
|
|
||||||
source shared.vim
|
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
|
|
||||||
func! Test_search_stat()
|
func Test_search_stat()
|
||||||
new
|
new
|
||||||
set shortmess-=S
|
set shortmess-=S
|
||||||
" Append 50 lines with text to search for, "foobar" appears 20 times
|
" Append 50 lines with text to search for, "foobar" appears 20 times
|
||||||
@ -47,7 +43,7 @@ func! Test_search_stat()
|
|||||||
call assert_match(pat .. stat, g:a)
|
call assert_match(pat .. stat, g:a)
|
||||||
call cursor(line('$'), 1)
|
call cursor(line('$'), 1)
|
||||||
let g:a = execute(':unsilent :norm! n')
|
let g:a = execute(':unsilent :norm! n')
|
||||||
let stat = '\[1/>99\] W'
|
let stat = 'W \[1/>99\]'
|
||||||
call assert_match(pat .. stat, g:a)
|
call assert_match(pat .. stat, g:a)
|
||||||
|
|
||||||
" Many matches
|
" Many matches
|
||||||
@ -57,7 +53,7 @@ func! Test_search_stat()
|
|||||||
call assert_match(pat .. stat, g:a)
|
call assert_match(pat .. stat, g:a)
|
||||||
call cursor(1, 1)
|
call cursor(1, 1)
|
||||||
let g:a = execute(':unsilent :norm! N')
|
let g:a = execute(':unsilent :norm! N')
|
||||||
let stat = '\[>99/>99\] W'
|
let stat = 'W \[>99/>99\]'
|
||||||
call assert_match(pat .. stat, g:a)
|
call assert_match(pat .. stat, g:a)
|
||||||
|
|
||||||
" right-left
|
" right-left
|
||||||
@ -89,7 +85,7 @@ func! Test_search_stat()
|
|||||||
call cursor('$',1)
|
call cursor('$',1)
|
||||||
let pat = 'raboof/\s\+'
|
let pat = 'raboof/\s\+'
|
||||||
let g:a = execute(':unsilent :norm! n')
|
let g:a = execute(':unsilent :norm! n')
|
||||||
let stat = '\[20/1\]'
|
let stat = 'W \[20/1\]'
|
||||||
call assert_match(pat .. stat, g:a)
|
call assert_match(pat .. stat, g:a)
|
||||||
call assert_match('search hit BOTTOM, continuing at TOP', g:a)
|
call assert_match('search hit BOTTOM, continuing at TOP', g:a)
|
||||||
set norl
|
set norl
|
||||||
@ -100,10 +96,10 @@ func! Test_search_stat()
|
|||||||
let @/ = 'foobar'
|
let @/ = 'foobar'
|
||||||
let pat = '?foobar\s\+'
|
let pat = '?foobar\s\+'
|
||||||
let g:a = execute(':unsilent :norm! N')
|
let g:a = execute(':unsilent :norm! N')
|
||||||
let stat = '\[20/20\]'
|
let stat = 'W \[20/20\]'
|
||||||
call assert_match(pat .. stat, g:a)
|
call assert_match(pat .. stat, g:a)
|
||||||
call assert_match('search hit TOP, continuing at BOTTOM', g:a)
|
call assert_match('search hit TOP, continuing at BOTTOM', g:a)
|
||||||
call assert_match('\[20/20\] W', Screenline(&lines))
|
call assert_match('W \[20/20\]', Screenline(&lines))
|
||||||
|
|
||||||
" normal, no match
|
" normal, no match
|
||||||
call cursor(1,1)
|
call cursor(1,1)
|
||||||
@ -162,11 +158,91 @@ func! Test_search_stat()
|
|||||||
let stat = '\[1/2\]'
|
let stat = '\[1/2\]'
|
||||||
call assert_notmatch(pat .. stat, g:a)
|
call assert_notmatch(pat .. stat, g:a)
|
||||||
|
|
||||||
" close the window
|
" normal, n comes from a silent mapping
|
||||||
|
" First test a normal mapping, then a silent mapping
|
||||||
|
call cursor(1,1)
|
||||||
|
nnoremap n n
|
||||||
|
let @/ = 'find this'
|
||||||
|
let pat = '/find this\s\+'
|
||||||
|
let g:a = execute(':unsilent :norm n')
|
||||||
|
let g:b = split(g:a, "\n")[-1]
|
||||||
|
let stat = '\[1/2\]'
|
||||||
|
call assert_match(pat .. stat, g:b)
|
||||||
|
nnoremap <silent> n n
|
||||||
|
call cursor(1,1)
|
||||||
|
let g:a = execute(':unsilent :norm n')
|
||||||
|
let g:b = split(g:a, "\n")[-1]
|
||||||
|
let stat = '\[1/2\]'
|
||||||
|
call assert_notmatch(pat .. stat, g:b)
|
||||||
|
call assert_match(stat, g:b)
|
||||||
|
" Test that the message is not truncated
|
||||||
|
" it would insert '...' into the output.
|
||||||
|
call assert_match('^\s\+' .. stat, g:b)
|
||||||
|
unmap n
|
||||||
|
|
||||||
|
" Clean up
|
||||||
set shortmess+=S
|
set shortmess+=S
|
||||||
|
" close the window
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_search_stat_foldopen()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
set shortmess-=S
|
||||||
|
setl foldenable foldmethod=indent foldopen-=search
|
||||||
|
call append(0, ['if', "\tfoo", "\tfoo", 'endif'])
|
||||||
|
let @/ = 'foo'
|
||||||
|
call cursor(1,1)
|
||||||
|
norm n
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xsearchstat1')
|
||||||
|
|
||||||
|
let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10})
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_searchstat_3', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "n")
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_searchstat_3', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "n")
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_searchstat_3', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xsearchstat1')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func! Test_search_stat_screendump()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
set shortmess-=S
|
||||||
|
" Append 50 lines with text to search for, "foobar" appears 20 times
|
||||||
|
call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20))
|
||||||
|
call setline(2, 'find this')
|
||||||
|
call setline(70, 'find this')
|
||||||
|
nnoremap n n
|
||||||
|
let @/ = 'find this'
|
||||||
|
call cursor(1,1)
|
||||||
|
norm n
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xsearchstat')
|
||||||
|
let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10})
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_searchstat_1', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>")
|
||||||
|
call term_sendkeys(buf, "gg0n")
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_searchstat_2', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xsearchstat')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_searchcount_in_statusline()
|
func Test_searchcount_in_statusline()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
]], messages={
|
]], messages={
|
||||||
{content = {{"/line [1/2] W"}}, kind = "search_count"}
|
{content = {{"/line W [1/2]"}}, kind = "search_count"}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
feed('n')
|
feed('n')
|
||||||
|
Loading…
Reference in New Issue
Block a user