From 485972dd64317e6a09ce7694cf0f903fb6d13cbd Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 27 May 2019 19:05:11 +0900 Subject: vim-patch:8.1.0629: "gn" selects the wrong text with a multi-line match Problem: "gn" selects the wrong text with a multi-line match. Solution: Get the end position from searchit() directly. (closes vim/vim#3695) https://github.com/vim/vim/commit/5d24a2257e597fd752e33b2c1e9c19cf9114a517 --- src/nvim/testdir/test_gn.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_gn.vim b/src/nvim/testdir/test_gn.vim index 405425a42b..5e74289b00 100644 --- a/src/nvim/testdir/test_gn.vim +++ b/src/nvim/testdir/test_gn.vim @@ -133,4 +133,23 @@ func Test_gn_command() set belloff&vim endfu +func Test_gn_multi_line() + new + call setline(1, [ + \ 'func Tm1()', + \ ' echo "one"', + \ 'endfunc', + \ 'func Tm2()', + \ ' echo "two"', + \ 'endfunc', + \ 'func Tm3()', + \ ' echo "three"', + \ 'endfunc', + \]) + /\v^func Tm\d\(\)\n.*\zs".*"\ze$ + normal jgnrx + call assert_equal(' echo xxxxx', getline(5)) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 777c2a25ce00f12b2d0dc26d594b1ba7ba10dcc6 Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 27 May 2019 12:26:32 +0900 Subject: vim-patch:8.1.1270: cannot see current match position Problem: Cannot see current match position. Solution: Show "3/44" when using the "n" command and "S" is not in 'shortmess'. (Christian Brabandt, closes vim/vim#4317) https://github.com/vim/vim/commit/9dfa3139198b38b28673e251a3756430065914e9 --- src/nvim/testdir/test_search_stat.vim | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/nvim/testdir/test_search_stat.vim (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search_stat.vim b/src/nvim/testdir/test_search_stat.vim new file mode 100644 index 0000000000..37e2fdaef5 --- /dev/null +++ b/src/nvim/testdir/test_search_stat.vim @@ -0,0 +1,108 @@ +" 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! + +func! Test_search_stat() + new + set shortmess-=S + call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) + + " 1) match at second line + call cursor(1, 1) + let @/ = 'fo*\(bar\?\)\?' + let g:a = execute(':unsilent :norm! n') + let stat = '\[2/50\]' + let pat = escape(@/, '()*?'). '\s\+' + call assert_match(pat .. stat, g:a) + + " 2) Match at last line + call cursor(line('$')-2, 1) + let g:a = execute(':unsilent :norm! n') + let stat = '\[50/50\]' + call assert_match(pat .. stat, g:a) + + " 3) No search stat + set shortmess+=S + call cursor(1, 1) + let stat = '\[2/50\]' + let g:a = execute(':unsilent :norm! n') + call assert_notmatch(pat .. stat, g:a) + set shortmess-=S + + " 4) Many matches + call cursor(line('$')-2, 1) + let @/ = '.' + let pat = escape(@/, '()*?'). '\s\+' + let g:a = execute(':unsilent :norm! n') + let stat = '\[>99/>99\]' + call assert_match(pat .. stat, g:a) + + " 5) Many matches + call cursor(1, 1) + let g:a = execute(':unsilent :norm! n') + let stat = '\[2/>99\]' + call assert_match(pat .. stat, g:a) + + " 6) right-left + if exists("+rightleft") + set rl + call cursor(1,1) + let @/ = 'foobar' + let pat = 'raboof/\s\+' + let g:a = execute(':unsilent :norm! n') + let stat = '\[20/2\]' + call assert_match(pat .. stat, g:a) + set norl + endif + + " 7) right-left bottom + if exists("+rightleft") + set rl + call cursor('$',1) + let pat = 'raboof?\s\+' + let g:a = execute(':unsilent :norm! N') + let stat = '\[20/20\]' + call assert_match(pat .. stat, g:a) + set norl + endif + + " 8) right-left back at top + if exists("+rightleft") + set rl + call cursor('$',1) + let pat = 'raboof/\s\+' + let g:a = execute(':unsilent :norm! n') + let stat = '\[20/1\]' + call assert_match(pat .. stat, g:a) + call assert_match('search hit BOTTOM, continuing at TOP', g:a) + set norl + endif + + " 9) normal, back at top + call cursor(1,1) + let @/ = 'foobar' + let pat = '?foobar\s\+' + let g:a = execute(':unsilent :norm! N') + let stat = '\[20/20\]' + call assert_match(pat .. stat, g:a) + call assert_match('search hit TOP, continuing at BOTTOM', g:a) + + " 10) normal, no match + call cursor(1,1) + let @/ = 'zzzzzz' + let g:a = '' + try + let g:a = execute(':unsilent :norm! n') + catch /^Vim\%((\a\+)\)\=:E486/ + let stat = '' + " error message is not redir'ed to g:a, it is empty + call assert_true(empty(g:a)) + catch + call assert_false(1) + endtry + + " close the window + set shortmess+=S + bwipe! +endfunc -- cgit From e8ca281d3b9243e66430f7f139c19aabead3de95 Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 27 May 2019 16:04:46 +0900 Subject: vim-patch:8.1.1283: delaying half a second after the top-bot message Problem: Delaying half a second after the top-bot message. Solution: Instead of the delay add "W" to the search count. https://github.com/vim/vim/commit/c7a10b35de70471519d104a74d402c63557f0512 --- src/nvim/testdir/test_search_stat.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search_stat.vim b/src/nvim/testdir/test_search_stat.vim index 37e2fdaef5..57dad81b81 100644 --- a/src/nvim/testdir/test_search_stat.vim +++ b/src/nvim/testdir/test_search_stat.vim @@ -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) -- cgit From 287fc076e137ea2fac8ac7288fd59eb28c4062cf Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 27 May 2019 16:20:40 +0900 Subject: vim-patch:8.1.1288: search stats don't show for mapped command Problem: Search stats don't show for mapped command. Solution: Remove SEARCH_PEEK from searchit flags. Add a test. (Christian Brabandt) https://github.com/vim/vim/commit/9ce3fa828d238ff28d57b0092bb37575e20010ec --- src/nvim/testdir/test_search_stat.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 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 57dad81b81..107cd54a0e 100644 --- a/src/nvim/testdir/test_search_stat.vim +++ b/src/nvim/testdir/test_search_stat.vim @@ -8,6 +8,7 @@ source shared.vim func! Test_search_stat() new set shortmess-=S + " Append 50 lines with text to search for, "foobar" appears 20 times call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) " 1) match at second line @@ -105,6 +106,30 @@ func! Test_search_stat() call assert_false(1) endtry + " 11) normal, n comes from a mapping + " Need to move over more than 64 lines to trigger char_avail(. + nnoremap n nzv + call cursor(1,1) + call append(50, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) + call setline(2, 'find this') + call setline(70, 'find this') + let @/ = 'find this' + let pat = '/find this\s\+' + let g:a = execute(':unsilent :norm n') + " g:a will contain several lines + let g:b = split(g:a, "\n")[-1] + let stat = '\[1/2\]' + call assert_match(pat .. stat, g:b) + unmap n + + " 11) normal, but silent + call cursor(1,1) + let @/ = 'find this' + let pat = '/find this\s\+' + let g:a = execute(':norm! n') + let stat = '\[1/2\]' + call assert_notmatch(pat .. stat, g:a) + " close the window set shortmess+=S bwipe! -- cgit From 2d567ac47ea48019e5e70c8b01b8be0be863a1ca Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 27 May 2019 16:34:03 +0900 Subject: vim-patch:8.1.1350: "W" for wrapping not shown when more than 99 matches Problem: "W" for wrapping not shown when more than 99 matches. Solution: Adjust check for length. (Masato Nishihata, closes vim/vim#4388) https://github.com/vim/vim/commit/dc6855af974f2ef553aceee619fadcb858e25d39 --- src/nvim/testdir/test_search_stat.vim | 8 ++++++++ 1 file changed, 8 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 107cd54a0e..322d137e2e 100644 --- a/src/nvim/testdir/test_search_stat.vim +++ b/src/nvim/testdir/test_search_stat.vim @@ -40,12 +40,20 @@ func! Test_search_stat() let g:a = execute(':unsilent :norm! n') let stat = '\[>99/>99\]' call assert_match(pat .. stat, g:a) + call cursor(line('$'), 1) + let g:a = execute(':unsilent :norm! n') + let stat = '\[1/>99\] W' + call assert_match(pat .. stat, g:a) " 5) Many matches call cursor(1, 1) let g:a = execute(':unsilent :norm! n') let stat = '\[2/>99\]' call assert_match(pat .. stat, g:a) + call cursor(1, 1) + let g:a = execute(':unsilent :norm! N') + let stat = '\[>99/>99\] W' + call assert_match(pat .. stat, g:a) " 6) right-left if exists("+rightleft") -- cgit From ec671c7048b4139c3323e7ff3932f93b62751edc Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 27 May 2019 17:08:29 +0900 Subject: vim-patch:8.1.1390: search stats are off when using count or offset Problem: Search stats are off when using count or offset. Solution: Recompute the stats when needed. (Masato Nishihata, closes vim/vim#4410) https://github.com/vim/vim/commit/8f46e4c4bde13fd5ad68a6670b79cc462b65fbec --- src/nvim/testdir/test_search_stat.vim | 43 +++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search_stat.vim b/src/nvim/testdir/test_search_stat.vim index 322d137e2e..0f52158560 100644 --- a/src/nvim/testdir/test_search_stat.vim +++ b/src/nvim/testdir/test_search_stat.vim @@ -11,7 +11,7 @@ func! Test_search_stat() " Append 50 lines with text to search for, "foobar" appears 20 times call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) - " 1) match at second line + " match at second line call cursor(1, 1) let @/ = 'fo*\(bar\?\)\?' let g:a = execute(':unsilent :norm! n') @@ -19,13 +19,13 @@ func! Test_search_stat() let pat = escape(@/, '()*?'). '\s\+' call assert_match(pat .. stat, g:a) - " 2) Match at last line + " Match at last line call cursor(line('$')-2, 1) let g:a = execute(':unsilent :norm! n') let stat = '\[50/50\]' call assert_match(pat .. stat, g:a) - " 3) No search stat + " No search stat set shortmess+=S call cursor(1, 1) let stat = '\[2/50\]' @@ -33,7 +33,7 @@ func! Test_search_stat() call assert_notmatch(pat .. stat, g:a) set shortmess-=S - " 4) Many matches + " Many matches call cursor(line('$')-2, 1) let @/ = '.' let pat = escape(@/, '()*?'). '\s\+' @@ -45,7 +45,7 @@ func! Test_search_stat() let stat = '\[1/>99\] W' call assert_match(pat .. stat, g:a) - " 5) Many matches + " Many matches call cursor(1, 1) let g:a = execute(':unsilent :norm! n') let stat = '\[2/>99\]' @@ -55,7 +55,7 @@ func! Test_search_stat() let stat = '\[>99/>99\] W' call assert_match(pat .. stat, g:a) - " 6) right-left + " right-left if exists("+rightleft") set rl call cursor(1,1) @@ -67,7 +67,7 @@ func! Test_search_stat() set norl endif - " 7) right-left bottom + " right-left bottom if exists("+rightleft") set rl call cursor('$',1) @@ -78,7 +78,7 @@ func! Test_search_stat() set norl endif - " 8) right-left back at top + " right-left back at top if exists("+rightleft") set rl call cursor('$',1) @@ -90,7 +90,7 @@ func! Test_search_stat() set norl endif - " 9) normal, back at bottom + " normal, back at bottom call cursor(1,1) let @/ = 'foobar' let pat = '?foobar\s\+' @@ -100,7 +100,7 @@ func! Test_search_stat() call assert_match('search hit TOP, continuing at BOTTOM', g:a) call assert_match('\[20/20\] W', Screenline(&lines)) - " 10) normal, no match + " normal, no match call cursor(1,1) let @/ = 'zzzzzz' let g:a = '' @@ -114,7 +114,26 @@ func! Test_search_stat() call assert_false(1) endtry - " 11) normal, n comes from a mapping + " with count + call cursor(1, 1) + let @/ = 'fo*\(bar\?\)\?' + let g:a = execute(':unsilent :norm! 2n') + let stat = '\[3/50\]' + let pat = escape(@/, '()*?'). '\s\+' + call assert_match(pat .. stat, g:a) + let g:a = execute(':unsilent :norm! 2n') + let stat = '\[5/50\]' + call assert_match(pat .. stat, g:a) + + " with offset + call cursor(1, 1) + call feedkeys("/fo*\\(bar\\?\\)\\?/+1\", 'tx') + let g:a = execute(':unsilent :norm! n') + let stat = '\[5/50\]' + let pat = escape(@/ .. '/+1', '()*?'). '\s\+' + call assert_match(pat .. stat, g:a) + + " normal, n comes from a mapping " Need to move over more than 64 lines to trigger char_avail(. nnoremap n nzv call cursor(1,1) @@ -130,7 +149,7 @@ func! Test_search_stat() call assert_match(pat .. stat, g:b) unmap n - " 11) normal, but silent + " normal, but silent call cursor(1,1) let @/ = 'find this' let pat = '/find this\s\+' -- cgit From 526382861495f92dc1e95a86d4a9b545459b7747 Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 27 May 2019 16:41:50 +0900 Subject: vim-patch:8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often Problem: Without "TS" in 'shortmess' get a hit-enter prompt often. Solution: Always truncate the search message. Also avoid putting it in the message history. (closes vim/vim#4413) https://github.com/vim/vim/commit/984f031fb02fe301a8dbf8a35b871c9f60b8f61e --- src/nvim/testdir/test_search_stat.vim | 3 +++ 1 file changed, 3 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 0f52158560..cf36f3214a 100644 --- a/src/nvim/testdir/test_search_stat.vim +++ b/src/nvim/testdir/test_search_stat.vim @@ -13,11 +13,14 @@ func! Test_search_stat() " match at second line call cursor(1, 1) + let messages_before = execute('messages') let @/ = 'fo*\(bar\?\)\?' let g:a = execute(':unsilent :norm! n') let stat = '\[2/50\]' let pat = escape(@/, '()*?'). '\s\+' call assert_match(pat .. stat, g:a) + " didn't get added to message history + call assert_equal(messages_before, execute('messages')) " Match at last line call cursor(line('$')-2, 1) -- cgit From 2a4e8a427e5e84f8e8a9477c0bfb8c1d376b3f1e Mon Sep 17 00:00:00 2001 From: erw7 Date: Fri, 7 Jun 2019 09:03:15 +0900 Subject: vim-patch:8.1.1475: search string not displayed when 'rightleft' is set Problem: Search string not displayed when 'rightleft' is set. Solution: Clear the right part of the old text. (closes vim/vim#4488, closes vim/vim#4489) https://github.com/vim/vim/commit/db294adc65d73ffa5cdf3d0ab45ccbf05b965414 --- src/nvim/testdir/test_search.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index f4fe4051e3..87cad241e2 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -609,3 +609,25 @@ func Test_search_match_at_curpos() close! endfunc + +func Test_search_display_pattern() + new + call setline(1, ['foo', 'bar', 'foobar']) + + call cursor(1, 1) + let @/ = 'foo' + let pat = escape(@/, '()*?'. '\s\+') + let g:a = execute(':unsilent :norm! n') + call assert_match(pat, g:a) + + " right-left + if exists("+rightleft") + set rl + call cursor(1, 1) + let @/ = 'foo' + let pat = 'oof/\s\+' + let g:a = execute(':unsilent :norm! n') + call assert_match(pat, g:a) + set norl + endif +endfunc -- cgit