Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 1 | " Tests for search_stats, when "S" is not in 'shortmess' |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 2 | |
Bram Moolenaar | 0f63ed3 | 2019-09-04 16:32:36 +0200 | [diff] [blame] | 3 | source check.vim |
| 4 | source screendump.vim |
Bram Moolenaar | c7a10b3 | 2019-05-06 21:37:18 +0200 | [diff] [blame] | 5 | |
Bram Moolenaar | 0f63ed3 | 2019-09-04 16:32:36 +0200 | [diff] [blame] | 6 | func Test_search_stat() |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 7 | new |
| 8 | set shortmess-=S |
Bram Moolenaar | 9ce3fa8 | 2019-05-07 21:29:11 +0200 | [diff] [blame] | 9 | " Append 50 lines with text to search for, "foobar" appears 20 times |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 10 | call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) |
| 11 | |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 12 | call cursor(1, 1) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 13 | |
| 14 | " searchcount() returns an empty dictionary when previous pattern was not set |
| 15 | call assert_equal({}, searchcount(#{pattern: ''})) |
| 16 | " but setting @/ should also work (even 'n' nor 'N' was executed) |
| 17 | " recompute the count when the last position is different. |
| 18 | call assert_equal( |
| 19 | \ #{current: 1, exact_match: 1, total: 40, incomplete: 0, maxcount: 99}, |
| 20 | \ searchcount(#{pattern: 'foo'})) |
| 21 | call assert_equal( |
| 22 | \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
| 23 | \ searchcount(#{pattern: 'fooooobar'})) |
| 24 | call assert_equal( |
| 25 | \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
| 26 | \ searchcount(#{pattern: 'fooooobar', pos: [2, 1, 0]})) |
| 27 | call assert_equal( |
| 28 | \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99}, |
| 29 | \ searchcount(#{pattern: 'fooooobar', pos: [3, 1, 0]})) |
Bram Moolenaar | 57f75a5 | 2020-06-02 22:06:21 +0200 | [diff] [blame] | 30 | " on last char of match |
| 31 | call assert_equal( |
| 32 | \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99}, |
| 33 | \ searchcount(#{pattern: 'fooooobar', pos: [3, 9, 0]})) |
| 34 | " on char after match |
| 35 | call assert_equal( |
| 36 | \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
| 37 | \ searchcount(#{pattern: 'fooooobar', pos: [3, 10, 0]})) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 38 | call assert_equal( |
| 39 | \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
| 40 | \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0]})) |
| 41 | call assert_equal( |
| 42 | \ #{current: 1, exact_match: 0, total: 2, incomplete: 2, maxcount: 1}, |
| 43 | \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0], maxcount: 1})) |
| 44 | call assert_equal( |
| 45 | \ #{current: 0, exact_match: 0, total: 2, incomplete: 2, maxcount: 1}, |
| 46 | \ searchcount(#{pattern: 'fooooobar', maxcount: 1})) |
| 47 | |
| 48 | " match at second line |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 49 | let messages_before = execute('messages') |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 50 | let @/ = 'fo*\(bar\?\)\?' |
| 51 | let g:a = execute(':unsilent :norm! n') |
| 52 | let stat = '\[2/50\]' |
| 53 | let pat = escape(@/, '()*?'). '\s\+' |
| 54 | call assert_match(pat .. stat, g:a) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 55 | call assert_equal( |
| 56 | \ #{current: 2, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
| 57 | \ searchcount(#{recompute: 0})) |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 58 | " didn't get added to message history |
| 59 | call assert_equal(messages_before, execute('messages')) |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 60 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 61 | " Match at last line |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 62 | call cursor(line('$')-2, 1) |
| 63 | let g:a = execute(':unsilent :norm! n') |
| 64 | let stat = '\[50/50\]' |
| 65 | call assert_match(pat .. stat, g:a) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 66 | call assert_equal( |
| 67 | \ #{current: 50, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
| 68 | \ searchcount(#{recompute: 0})) |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 69 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 70 | " No search stat |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 71 | set shortmess+=S |
| 72 | call cursor(1, 1) |
| 73 | let stat = '\[2/50\]' |
| 74 | let g:a = execute(':unsilent :norm! n') |
| 75 | call assert_notmatch(pat .. stat, g:a) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 76 | " n does not update search stat |
| 77 | call assert_equal( |
| 78 | \ #{current: 50, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
| 79 | \ searchcount(#{recompute: 0})) |
| 80 | call assert_equal( |
| 81 | \ #{current: 2, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
| 82 | \ searchcount(#{recompute: v:true})) |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 83 | set shortmess-=S |
| 84 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 85 | " Many matches |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 86 | call cursor(line('$')-2, 1) |
| 87 | let @/ = '.' |
| 88 | let pat = escape(@/, '()*?'). '\s\+' |
| 89 | let g:a = execute(':unsilent :norm! n') |
| 90 | let stat = '\[>99/>99\]' |
| 91 | call assert_match(pat .. stat, g:a) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 92 | call assert_equal( |
| 93 | \ #{current: 100, exact_match: 0, total: 100, incomplete: 2, maxcount: 99}, |
| 94 | \ searchcount(#{recompute: 0})) |
| 95 | call assert_equal( |
| 96 | \ #{current: 272, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
Bram Moolenaar | ea6561a | 2020-06-01 21:32:45 +0200 | [diff] [blame] | 97 | \ searchcount(#{recompute: v:true, maxcount: 0, timeout: 200})) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 98 | call assert_equal( |
| 99 | \ #{current: 1, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
Bram Moolenaar | ea6561a | 2020-06-01 21:32:45 +0200 | [diff] [blame] | 100 | \ searchcount(#{recompute: 1, maxcount: 0, pos: [1, 1, 0], timeout: 200})) |
Bram Moolenaar | dc6855a | 2019-05-18 19:26:29 +0200 | [diff] [blame] | 101 | call cursor(line('$'), 1) |
| 102 | let g:a = execute(':unsilent :norm! n') |
Bram Moolenaar | 16b58ae | 2019-09-06 20:40:21 +0200 | [diff] [blame] | 103 | let stat = 'W \[1/>99\]' |
Bram Moolenaar | dc6855a | 2019-05-18 19:26:29 +0200 | [diff] [blame] | 104 | call assert_match(pat .. stat, g:a) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 105 | call assert_equal( |
| 106 | \ #{current: 1, exact_match: 1, total: 100, incomplete: 2, maxcount: 99}, |
| 107 | \ searchcount(#{recompute: 0})) |
| 108 | call assert_equal( |
| 109 | \ #{current: 1, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
Bram Moolenaar | ea6561a | 2020-06-01 21:32:45 +0200 | [diff] [blame] | 110 | \ searchcount(#{recompute: 1, maxcount: 0, timeout: 200})) |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 111 | call assert_equal( |
| 112 | \ #{current: 271, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
Bram Moolenaar | ea6561a | 2020-06-01 21:32:45 +0200 | [diff] [blame] | 113 | \ searchcount(#{recompute: 1, maxcount: 0, pos: [line('$')-2, 1, 0], timeout: 200})) |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 114 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 115 | " Many matches |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 116 | call cursor(1, 1) |
| 117 | let g:a = execute(':unsilent :norm! n') |
| 118 | let stat = '\[2/>99\]' |
| 119 | call assert_match(pat .. stat, g:a) |
Bram Moolenaar | dc6855a | 2019-05-18 19:26:29 +0200 | [diff] [blame] | 120 | call cursor(1, 1) |
| 121 | let g:a = execute(':unsilent :norm! N') |
Bram Moolenaar | 16b58ae | 2019-09-06 20:40:21 +0200 | [diff] [blame] | 122 | let stat = 'W \[>99/>99\]' |
Bram Moolenaar | dc6855a | 2019-05-18 19:26:29 +0200 | [diff] [blame] | 123 | call assert_match(pat .. stat, g:a) |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 124 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 125 | " right-left |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 126 | if exists("+rightleft") |
| 127 | set rl |
| 128 | call cursor(1,1) |
| 129 | let @/ = 'foobar' |
| 130 | let pat = 'raboof/\s\+' |
| 131 | let g:a = execute(':unsilent :norm! n') |
| 132 | let stat = '\[20/2\]' |
| 133 | call assert_match(pat .. stat, g:a) |
| 134 | set norl |
| 135 | endif |
| 136 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 137 | " right-left bottom |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 138 | if exists("+rightleft") |
| 139 | set rl |
| 140 | call cursor('$',1) |
| 141 | let pat = 'raboof?\s\+' |
| 142 | let g:a = execute(':unsilent :norm! N') |
| 143 | let stat = '\[20/20\]' |
| 144 | call assert_match(pat .. stat, g:a) |
| 145 | set norl |
| 146 | endif |
| 147 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 148 | " right-left back at top |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 149 | if exists("+rightleft") |
| 150 | set rl |
| 151 | call cursor('$',1) |
| 152 | let pat = 'raboof/\s\+' |
| 153 | let g:a = execute(':unsilent :norm! n') |
Bram Moolenaar | 16b58ae | 2019-09-06 20:40:21 +0200 | [diff] [blame] | 154 | let stat = 'W \[20/1\]' |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 155 | call assert_match(pat .. stat, g:a) |
| 156 | call assert_match('search hit BOTTOM, continuing at TOP', g:a) |
| 157 | set norl |
| 158 | endif |
| 159 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 160 | " normal, back at bottom |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 161 | call cursor(1,1) |
| 162 | let @/ = 'foobar' |
| 163 | let pat = '?foobar\s\+' |
| 164 | let g:a = execute(':unsilent :norm! N') |
Bram Moolenaar | 16b58ae | 2019-09-06 20:40:21 +0200 | [diff] [blame] | 165 | let stat = 'W \[20/20\]' |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 166 | call assert_match(pat .. stat, g:a) |
| 167 | call assert_match('search hit TOP, continuing at BOTTOM', g:a) |
Bram Moolenaar | 16b58ae | 2019-09-06 20:40:21 +0200 | [diff] [blame] | 168 | call assert_match('W \[20/20\]', Screenline(&lines)) |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 169 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 170 | " normal, no match |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 171 | call cursor(1,1) |
| 172 | let @/ = 'zzzzzz' |
| 173 | let g:a = '' |
| 174 | try |
| 175 | let g:a = execute(':unsilent :norm! n') |
| 176 | catch /^Vim\%((\a\+)\)\=:E486/ |
| 177 | let stat = '' |
| 178 | " error message is not redir'ed to g:a, it is empty |
| 179 | call assert_true(empty(g:a)) |
| 180 | catch |
| 181 | call assert_false(1) |
| 182 | endtry |
| 183 | |
Bram Moolenaar | 8f46e4c | 2019-05-24 22:08:15 +0200 | [diff] [blame] | 184 | " with count |
| 185 | call cursor(1, 1) |
| 186 | let @/ = 'fo*\(bar\?\)\?' |
| 187 | let g:a = execute(':unsilent :norm! 2n') |
| 188 | let stat = '\[3/50\]' |
| 189 | let pat = escape(@/, '()*?'). '\s\+' |
| 190 | call assert_match(pat .. stat, g:a) |
| 191 | let g:a = execute(':unsilent :norm! 2n') |
| 192 | let stat = '\[5/50\]' |
| 193 | call assert_match(pat .. stat, g:a) |
| 194 | |
| 195 | " with offset |
| 196 | call cursor(1, 1) |
| 197 | call feedkeys("/fo*\\(bar\\?\\)\\?/+1\<cr>", 'tx') |
| 198 | let g:a = execute(':unsilent :norm! n') |
| 199 | let stat = '\[5/50\]' |
| 200 | let pat = escape(@/ .. '/+1', '()*?'). '\s\+' |
| 201 | call assert_match(pat .. stat, g:a) |
| 202 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 203 | " normal, n comes from a mapping |
Bram Moolenaar | 9ce3fa8 | 2019-05-07 21:29:11 +0200 | [diff] [blame] | 204 | " Need to move over more than 64 lines to trigger char_avail(. |
| 205 | nnoremap n nzv |
| 206 | call cursor(1,1) |
| 207 | call append(50, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) |
| 208 | call setline(2, 'find this') |
| 209 | call setline(70, 'find this') |
| 210 | let @/ = 'find this' |
| 211 | let pat = '/find this\s\+' |
| 212 | let g:a = execute(':unsilent :norm n') |
| 213 | " g:a will contain several lines |
| 214 | let g:b = split(g:a, "\n")[-1] |
| 215 | let stat = '\[1/2\]' |
| 216 | call assert_match(pat .. stat, g:b) |
| 217 | unmap n |
| 218 | |
Bram Moolenaar | 984f031 | 2019-05-24 13:11:47 +0200 | [diff] [blame] | 219 | " normal, but silent |
Bram Moolenaar | 9ce3fa8 | 2019-05-07 21:29:11 +0200 | [diff] [blame] | 220 | call cursor(1,1) |
| 221 | let @/ = 'find this' |
| 222 | let pat = '/find this\s\+' |
| 223 | let g:a = execute(':norm! n') |
| 224 | let stat = '\[1/2\]' |
| 225 | call assert_notmatch(pat .. stat, g:a) |
| 226 | |
Bram Moolenaar | 19e8ac7 | 2019-09-03 22:23:38 +0200 | [diff] [blame] | 227 | " normal, n comes from a silent mapping |
| 228 | " First test a normal mapping, then a silent mapping |
| 229 | call cursor(1,1) |
| 230 | nnoremap n n |
| 231 | let @/ = 'find this' |
| 232 | let pat = '/find this\s\+' |
| 233 | let g:a = execute(':unsilent :norm n') |
| 234 | let g:b = split(g:a, "\n")[-1] |
| 235 | let stat = '\[1/2\]' |
| 236 | call assert_match(pat .. stat, g:b) |
| 237 | nnoremap <silent> n n |
| 238 | call cursor(1,1) |
| 239 | let g:a = execute(':unsilent :norm n') |
| 240 | let g:b = split(g:a, "\n")[-1] |
| 241 | let stat = '\[1/2\]' |
| 242 | call assert_notmatch(pat .. stat, g:b) |
| 243 | call assert_match(stat, g:b) |
Bram Moolenaar | 0f63ed3 | 2019-09-04 16:32:36 +0200 | [diff] [blame] | 244 | " Test that the message is not truncated |
| 245 | " it would insert '...' into the output. |
| 246 | call assert_match('^\s\+' .. stat, g:b) |
Bram Moolenaar | 19e8ac7 | 2019-09-03 22:23:38 +0200 | [diff] [blame] | 247 | unmap n |
| 248 | |
Bram Moolenaar | e8f5ec0 | 2020-06-01 17:28:35 +0200 | [diff] [blame] | 249 | " Time out |
| 250 | %delete _ |
| 251 | call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 100000)) |
| 252 | call cursor(1, 1) |
| 253 | call assert_equal(1, searchcount(#{pattern: 'foo', maxcount: 0, timeout: 1}).incomplete) |
| 254 | |
Bram Moolenaar | 19e8ac7 | 2019-09-03 22:23:38 +0200 | [diff] [blame] | 255 | " Clean up |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 256 | set shortmess+=S |
Bram Moolenaar | 19e8ac7 | 2019-09-03 22:23:38 +0200 | [diff] [blame] | 257 | " close the window |
Bram Moolenaar | 9dfa313 | 2019-05-04 21:08:40 +0200 | [diff] [blame] | 258 | bwipe! |
| 259 | endfunc |
Bram Moolenaar | 0f63ed3 | 2019-09-04 16:32:36 +0200 | [diff] [blame] | 260 | |
Bram Moolenaar | 1468162 | 2020-06-03 22:57:39 +0200 | [diff] [blame] | 261 | func Test_searchcount_fails() |
| 262 | call assert_fails('echo searchcount("boo!")', 'E715:') |
| 263 | endfunc |
| 264 | |
Bram Moolenaar | 442a853 | 2020-06-04 20:56:09 +0200 | [diff] [blame] | 265 | func Test_searchcount_in_statusline() |
| 266 | CheckScreendump |
| 267 | |
| 268 | let lines =<< trim END |
| 269 | set shortmess-=S |
| 270 | call append(0, 'this is something') |
| 271 | function TestSearchCount() abort |
| 272 | let search_count = searchcount() |
| 273 | if !empty(search_count) |
| 274 | return '[' . search_count.current . '/' . search_count.total . ']' |
| 275 | else |
| 276 | return '' |
| 277 | endif |
| 278 | endfunction |
| 279 | set hlsearch |
| 280 | set laststatus=2 statusline+=%{TestSearchCount()} |
| 281 | END |
| 282 | call writefile(lines, 'Xsearchstatusline') |
| 283 | let buf = RunVimInTerminal('-S Xsearchstatusline', #{rows: 10}) |
| 284 | call TermWait(buf) |
| 285 | call term_sendkeys(buf, "/something") |
| 286 | call VerifyScreenDump(buf, 'Test_searchstat_4', {}) |
| 287 | |
| 288 | call term_sendkeys(buf, "\<Esc>") |
| 289 | call StopVimInTerminal(buf) |
| 290 | call delete('Xsearchstatusline') |
| 291 | endfunc |
| 292 | |
Bram Moolenaar | 6cb0726 | 2020-05-29 22:49:43 +0200 | [diff] [blame] | 293 | func Test_search_stat_foldopen() |
| 294 | CheckScreendump |
| 295 | |
| 296 | let lines =<< trim END |
| 297 | set shortmess-=S |
| 298 | setl foldenable foldmethod=indent foldopen-=search |
| 299 | call append(0, ['if', "\tfoo", "\tfoo", 'endif']) |
| 300 | let @/ = 'foo' |
| 301 | call cursor(1,1) |
| 302 | norm n |
| 303 | END |
| 304 | call writefile(lines, 'Xsearchstat1') |
| 305 | |
| 306 | let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10}) |
| 307 | call TermWait(buf) |
| 308 | call VerifyScreenDump(buf, 'Test_searchstat_3', {}) |
| 309 | |
| 310 | call term_sendkeys(buf, "n") |
| 311 | call TermWait(buf) |
| 312 | call VerifyScreenDump(buf, 'Test_searchstat_3', {}) |
| 313 | |
| 314 | call term_sendkeys(buf, "n") |
| 315 | call TermWait(buf) |
| 316 | call VerifyScreenDump(buf, 'Test_searchstat_3', {}) |
| 317 | |
| 318 | call StopVimInTerminal(buf) |
| 319 | call delete('Xsearchstat1') |
| 320 | endfunc |
| 321 | |
Bram Moolenaar | 0f63ed3 | 2019-09-04 16:32:36 +0200 | [diff] [blame] | 322 | func! Test_search_stat_screendump() |
| 323 | CheckScreendump |
| 324 | |
| 325 | let lines =<< trim END |
| 326 | set shortmess-=S |
| 327 | " Append 50 lines with text to search for, "foobar" appears 20 times |
| 328 | call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20)) |
| 329 | call setline(2, 'find this') |
| 330 | call setline(70, 'find this') |
| 331 | nnoremap n n |
| 332 | let @/ = 'find this' |
| 333 | call cursor(1,1) |
| 334 | norm n |
| 335 | END |
| 336 | call writefile(lines, 'Xsearchstat') |
| 337 | let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 338 | call TermWait(buf) |
Bram Moolenaar | 0f63ed3 | 2019-09-04 16:32:36 +0200 | [diff] [blame] | 339 | call VerifyScreenDump(buf, 'Test_searchstat_1', {}) |
| 340 | |
| 341 | call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>") |
| 342 | call term_sendkeys(buf, "gg0n") |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 343 | call TermWait(buf) |
Bram Moolenaar | 0f63ed3 | 2019-09-04 16:32:36 +0200 | [diff] [blame] | 344 | call VerifyScreenDump(buf, 'Test_searchstat_2', {}) |
| 345 | |
| 346 | call StopVimInTerminal(buf) |
| 347 | call delete('Xsearchstat') |
| 348 | endfunc |