From 4327fe8da54ad090e3ca08473ff198ad7cc1f448 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 12 Sep 2020 19:26:56 -0400 Subject: vim-patch:8.2.0902: using searchcount() in 'statusline' causes an error Problem: Using searchcount() in 'statusline' causes an error. Solution: Avoid saving/restoring the search patten recursively. (closes vim/vim#6194) https://github.com/vim/vim/commit/442a85369f3eb9834dbab42add45f7c4106700f4 --- src/nvim/testdir/test_search_stat.vim | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search_stat.vim b/src/nvim/testdir/test_search_stat.vim index cf36f3214a..fa620b4e00 100644 --- a/src/nvim/testdir/test_search_stat.vim +++ b/src/nvim/testdir/test_search_stat.vim @@ -4,6 +4,8 @@ " as test! source shared.vim +source screendump.vim +source check.vim func! Test_search_stat() new @@ -164,3 +166,31 @@ func! Test_search_stat() set shortmess+=S bwipe! endfunc + +func Test_searchcount_in_statusline() + CheckScreendump + + let lines =<< trim END + set shortmess-=S + call append(0, 'this is something') + function TestSearchCount() abort + let search_count = searchcount() + if !empty(search_count) + return '[' . search_count.current . '/' . search_count.total . ']' + else + return '' + endif + endfunction + set hlsearch + set laststatus=2 statusline+=%{TestSearchCount()} + END + call writefile(lines, 'Xsearchstatusline') + let buf = RunVimInTerminal('-S Xsearchstatusline', #{rows: 10}) + call TermWait(buf) + call term_sendkeys(buf, "/something") + call VerifyScreenDump(buf, 'Test_searchstat_4', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) + call delete('Xsearchstatusline') +endfunc -- cgit