annotate src/testdir/test_search_stat.vim @ 16533:5e25171e0e75 v8.1.1270

patch 8.1.1270: cannot see current match position commit https://github.com/vim/vim/commit/9dfa3139198b38b28673e251a3756430065914e9 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 4 21:08:40 2019 +0200 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 #4317)
author Bram Moolenaar <Bram@vim.org>
date Sat, 04 May 2019 21:15:05 +0200
parents
children 8d0ea09e2d81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for search_stats, when "S" is not in 'shortmess'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 "
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 " This test is fragile, it might not work interactively, but it works when run
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 " as test!
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 func! Test_search_stat()
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 new
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 set shortmess-=S
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10))
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 " 1) match at second line
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 call cursor(1, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let @/ = 'fo*\(bar\?\)\?'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 let stat = '\[2/50\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 let pat = escape(@/, '()*?'). '\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 " 2) Match at last line
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 call cursor(line('$')-2, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 let stat = '\[50/50\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 " 3) No search stat
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 set shortmess+=S
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 call cursor(1, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 let stat = '\[2/50\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 call assert_notmatch(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 set shortmess-=S
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 " 4) Many matches
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call cursor(line('$')-2, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 let @/ = '.'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 let pat = escape(@/, '()*?'). '\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 let stat = '\[>99/>99\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 " 5) Many matches
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 call cursor(1, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 let stat = '\[2/>99\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 " 6) right-left
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 if exists("+rightleft")
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 set rl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 call cursor(1,1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 let @/ = 'foobar'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 let pat = 'raboof/\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 let stat = '\[20/2\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 set norl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 endif
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 " 7) right-left bottom
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 if exists("+rightleft")
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 set rl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 call cursor('$',1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 let pat = 'raboof?\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 let g:a = execute(':unsilent :norm! N')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 let stat = '\[20/20\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 set norl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 endif
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 " 8) right-left back at top
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 if exists("+rightleft")
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 set rl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 call cursor('$',1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 let pat = 'raboof/\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 let stat = '\[20/1\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 call assert_match('search hit BOTTOM, continuing at TOP', g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 set norl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 endif
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 " 9) normal, back at top
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 call cursor(1,1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 let @/ = 'foobar'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 let pat = '?foobar\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 let g:a = execute(':unsilent :norm! N')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 let stat = '\[20/20\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 call assert_match(pat .. stat, g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 call assert_match('search hit TOP, continuing at BOTTOM', g:a)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 " 10) normal, no match
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 call cursor(1,1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 let @/ = 'zzzzzz'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 let g:a = ''
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 try
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 let g:a = execute(':unsilent :norm! n')
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 catch /^Vim\%((\a\+)\)\=:E486/
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 let stat = ''
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 " error message is not redir'ed to g:a, it is empty
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 call assert_true(empty(g:a))
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 catch
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 call assert_false(1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 endtry
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 " close the window
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 set shortmess+=S
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 bwipe!
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 endfunc