Mercurial > vim
comparison src/testdir/test_search_stat.vim @ 16746:73ff6357da5b v8.1.1375
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
commit https://github.com/vim/vim/commit/984f031fb02fe301a8dbf8a35b871c9f60b8f61e
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 24 13:11:47 2019 +0200
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 #4413)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 May 2019 13:15:05 +0200 |
parents | b1756c303066 |
children | 7d4c814a8554 |
comparison
equal
deleted
inserted
replaced
16745:4ac8cb8c8146 | 16746:73ff6357da5b |
---|---|
9 new | 9 new |
10 set shortmess-=S | 10 set shortmess-=S |
11 " Append 50 lines with text to search for, "foobar" appears 20 times | 11 " Append 50 lines with text to search for, "foobar" appears 20 times |
12 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) | 12 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) |
13 | 13 |
14 " 1) match at second line | 14 " match at second line |
15 call cursor(1, 1) | 15 call cursor(1, 1) |
16 let messages_before = execute('messages') | |
16 let @/ = 'fo*\(bar\?\)\?' | 17 let @/ = 'fo*\(bar\?\)\?' |
17 let g:a = execute(':unsilent :norm! n') | 18 let g:a = execute(':unsilent :norm! n') |
18 let stat = '\[2/50\]' | 19 let stat = '\[2/50\]' |
19 let pat = escape(@/, '()*?'). '\s\+' | 20 let pat = escape(@/, '()*?'). '\s\+' |
20 call assert_match(pat .. stat, g:a) | 21 call assert_match(pat .. stat, g:a) |
22 " didn't get added to message history | |
23 call assert_equal(messages_before, execute('messages')) | |
21 | 24 |
22 " 2) Match at last line | 25 " Match at last line |
23 call cursor(line('$')-2, 1) | 26 call cursor(line('$')-2, 1) |
24 let g:a = execute(':unsilent :norm! n') | 27 let g:a = execute(':unsilent :norm! n') |
25 let stat = '\[50/50\]' | 28 let stat = '\[50/50\]' |
26 call assert_match(pat .. stat, g:a) | 29 call assert_match(pat .. stat, g:a) |
27 | 30 |
28 " 3) No search stat | 31 " No search stat |
29 set shortmess+=S | 32 set shortmess+=S |
30 call cursor(1, 1) | 33 call cursor(1, 1) |
31 let stat = '\[2/50\]' | 34 let stat = '\[2/50\]' |
32 let g:a = execute(':unsilent :norm! n') | 35 let g:a = execute(':unsilent :norm! n') |
33 call assert_notmatch(pat .. stat, g:a) | 36 call assert_notmatch(pat .. stat, g:a) |
34 set shortmess-=S | 37 set shortmess-=S |
35 | 38 |
36 " 4) Many matches | 39 " Many matches |
37 call cursor(line('$')-2, 1) | 40 call cursor(line('$')-2, 1) |
38 let @/ = '.' | 41 let @/ = '.' |
39 let pat = escape(@/, '()*?'). '\s\+' | 42 let pat = escape(@/, '()*?'). '\s\+' |
40 let g:a = execute(':unsilent :norm! n') | 43 let g:a = execute(':unsilent :norm! n') |
41 let stat = '\[>99/>99\]' | 44 let stat = '\[>99/>99\]' |
43 call cursor(line('$'), 1) | 46 call cursor(line('$'), 1) |
44 let g:a = execute(':unsilent :norm! n') | 47 let g:a = execute(':unsilent :norm! n') |
45 let stat = '\[1/>99\] W' | 48 let stat = '\[1/>99\] W' |
46 call assert_match(pat .. stat, g:a) | 49 call assert_match(pat .. stat, g:a) |
47 | 50 |
48 " 5) Many matches | 51 " Many matches |
49 call cursor(1, 1) | 52 call cursor(1, 1) |
50 let g:a = execute(':unsilent :norm! n') | 53 let g:a = execute(':unsilent :norm! n') |
51 let stat = '\[2/>99\]' | 54 let stat = '\[2/>99\]' |
52 call assert_match(pat .. stat, g:a) | 55 call assert_match(pat .. stat, g:a) |
53 call cursor(1, 1) | 56 call cursor(1, 1) |
54 let g:a = execute(':unsilent :norm! N') | 57 let g:a = execute(':unsilent :norm! N') |
55 let stat = '\[>99/>99\] W' | 58 let stat = '\[>99/>99\] W' |
56 call assert_match(pat .. stat, g:a) | 59 call assert_match(pat .. stat, g:a) |
57 | 60 |
58 " 6) right-left | 61 " right-left |
59 if exists("+rightleft") | 62 if exists("+rightleft") |
60 set rl | 63 set rl |
61 call cursor(1,1) | 64 call cursor(1,1) |
62 let @/ = 'foobar' | 65 let @/ = 'foobar' |
63 let pat = 'raboof/\s\+' | 66 let pat = 'raboof/\s\+' |
65 let stat = '\[20/2\]' | 68 let stat = '\[20/2\]' |
66 call assert_match(pat .. stat, g:a) | 69 call assert_match(pat .. stat, g:a) |
67 set norl | 70 set norl |
68 endif | 71 endif |
69 | 72 |
70 " 7) right-left bottom | 73 " right-left bottom |
71 if exists("+rightleft") | 74 if exists("+rightleft") |
72 set rl | 75 set rl |
73 call cursor('$',1) | 76 call cursor('$',1) |
74 let pat = 'raboof?\s\+' | 77 let pat = 'raboof?\s\+' |
75 let g:a = execute(':unsilent :norm! N') | 78 let g:a = execute(':unsilent :norm! N') |
76 let stat = '\[20/20\]' | 79 let stat = '\[20/20\]' |
77 call assert_match(pat .. stat, g:a) | 80 call assert_match(pat .. stat, g:a) |
78 set norl | 81 set norl |
79 endif | 82 endif |
80 | 83 |
81 " 8) right-left back at top | 84 " right-left back at top |
82 if exists("+rightleft") | 85 if exists("+rightleft") |
83 set rl | 86 set rl |
84 call cursor('$',1) | 87 call cursor('$',1) |
85 let pat = 'raboof/\s\+' | 88 let pat = 'raboof/\s\+' |
86 let g:a = execute(':unsilent :norm! n') | 89 let g:a = execute(':unsilent :norm! n') |
88 call assert_match(pat .. stat, g:a) | 91 call assert_match(pat .. stat, g:a) |
89 call assert_match('search hit BOTTOM, continuing at TOP', g:a) | 92 call assert_match('search hit BOTTOM, continuing at TOP', g:a) |
90 set norl | 93 set norl |
91 endif | 94 endif |
92 | 95 |
93 " 9) normal, back at bottom | 96 " normal, back at bottom |
94 call cursor(1,1) | 97 call cursor(1,1) |
95 let @/ = 'foobar' | 98 let @/ = 'foobar' |
96 let pat = '?foobar\s\+' | 99 let pat = '?foobar\s\+' |
97 let g:a = execute(':unsilent :norm! N') | 100 let g:a = execute(':unsilent :norm! N') |
98 let stat = '\[20/20\]' | 101 let stat = '\[20/20\]' |
99 call assert_match(pat .. stat, g:a) | 102 call assert_match(pat .. stat, g:a) |
100 call assert_match('search hit TOP, continuing at BOTTOM', g:a) | 103 call assert_match('search hit TOP, continuing at BOTTOM', g:a) |
101 call assert_match('\[20/20\] W', Screenline(&lines)) | 104 call assert_match('\[20/20\] W', Screenline(&lines)) |
102 | 105 |
103 " 10) normal, no match | 106 " normal, no match |
104 call cursor(1,1) | 107 call cursor(1,1) |
105 let @/ = 'zzzzzz' | 108 let @/ = 'zzzzzz' |
106 let g:a = '' | 109 let g:a = '' |
107 try | 110 try |
108 let g:a = execute(':unsilent :norm! n') | 111 let g:a = execute(':unsilent :norm! n') |
112 call assert_true(empty(g:a)) | 115 call assert_true(empty(g:a)) |
113 catch | 116 catch |
114 call assert_false(1) | 117 call assert_false(1) |
115 endtry | 118 endtry |
116 | 119 |
117 " 11) normal, n comes from a mapping | 120 " normal, n comes from a mapping |
118 " Need to move over more than 64 lines to trigger char_avail(. | 121 " Need to move over more than 64 lines to trigger char_avail(. |
119 nnoremap n nzv | 122 nnoremap n nzv |
120 call cursor(1,1) | 123 call cursor(1,1) |
121 call append(50, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) | 124 call append(50, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) |
122 call setline(2, 'find this') | 125 call setline(2, 'find this') |
128 let g:b = split(g:a, "\n")[-1] | 131 let g:b = split(g:a, "\n")[-1] |
129 let stat = '\[1/2\]' | 132 let stat = '\[1/2\]' |
130 call assert_match(pat .. stat, g:b) | 133 call assert_match(pat .. stat, g:b) |
131 unmap n | 134 unmap n |
132 | 135 |
133 " 11) normal, but silent | 136 " normal, but silent |
134 call cursor(1,1) | 137 call cursor(1,1) |
135 let @/ = 'find this' | 138 let @/ = 'find this' |
136 let pat = '/find this\s\+' | 139 let pat = '/find this\s\+' |
137 let g:a = execute(':norm! n') | 140 let g:a = execute(':norm! n') |
138 let stat = '\[1/2\]' | 141 let stat = '\[1/2\]' |