blob: b57b7ba7b09312a4f3a13214be7a322df59c464e [file] [log] [blame]
Bram Moolenaar9dfa3132019-05-04 21:08:40 +02001" Tests for search_stats, when "S" is not in 'shortmess'
Bram Moolenaar9dfa3132019-05-04 21:08:40 +02002
Bram Moolenaar0f63ed32019-09-04 16:32:36 +02003source check.vim
4source screendump.vim
Bram Moolenaarc7a10b32019-05-06 21:37:18 +02005
Bram Moolenaar0f63ed32019-09-04 16:32:36 +02006func Test_search_stat()
Bram Moolenaar9dfa3132019-05-04 21:08:40 +02007 new
8 set shortmess-=S
Bram Moolenaar9ce3fa82019-05-07 21:29:11 +02009 " Append 50 lines with text to search for, "foobar" appears 20 times
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020010 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10))
11
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020012 call cursor(1, 1)
Bram Moolenaare8f5ec02020-06-01 17:28:35 +020013
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 Moolenaar57f75a52020-06-02 22:06:21 +020030 " 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 Moolenaare8f5ec02020-06-01 17:28:35 +020038 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 Moolenaar984f0312019-05-24 13:11:47 +020049 let messages_before = execute('messages')
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020050 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 Moolenaare8f5ec02020-06-01 17:28:35 +020055 call assert_equal(
56 \ #{current: 2, exact_match: 1, total: 50, incomplete: 0, maxcount: 99},
57 \ searchcount(#{recompute: 0}))
Bram Moolenaar984f0312019-05-24 13:11:47 +020058 " didn't get added to message history
59 call assert_equal(messages_before, execute('messages'))
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020060
Bram Moolenaar984f0312019-05-24 13:11:47 +020061 " Match at last line
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020062 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 Moolenaare8f5ec02020-06-01 17:28:35 +020066 call assert_equal(
67 \ #{current: 50, exact_match: 1, total: 50, incomplete: 0, maxcount: 99},
68 \ searchcount(#{recompute: 0}))
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020069
Bram Moolenaar984f0312019-05-24 13:11:47 +020070 " No search stat
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020071 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 Moolenaare8f5ec02020-06-01 17:28:35 +020076 " 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 Moolenaar9dfa3132019-05-04 21:08:40 +020083 set shortmess-=S
84
Bram Moolenaar984f0312019-05-24 13:11:47 +020085 " Many matches
Bram Moolenaar9dfa3132019-05-04 21:08:40 +020086 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 Moolenaare8f5ec02020-06-01 17:28:35 +020092 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 Moolenaarea6561a2020-06-01 21:32:45 +020097 \ searchcount(#{recompute: v:true, maxcount: 0, timeout: 200}))
Bram Moolenaare8f5ec02020-06-01 17:28:35 +020098 call assert_equal(
99 \ #{current: 1, exact_match: 1, total: 280, incomplete: 0, maxcount: 0},
Bram Moolenaarea6561a2020-06-01 21:32:45 +0200100 \ searchcount(#{recompute: 1, maxcount: 0, pos: [1, 1, 0], timeout: 200}))
Bram Moolenaardc6855a2019-05-18 19:26:29 +0200101 call cursor(line('$'), 1)
102 let g:a = execute(':unsilent :norm! n')
Bram Moolenaar16b58ae2019-09-06 20:40:21 +0200103 let stat = 'W \[1/>99\]'
Bram Moolenaardc6855a2019-05-18 19:26:29 +0200104 call assert_match(pat .. stat, g:a)
Bram Moolenaare8f5ec02020-06-01 17:28:35 +0200105 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 Moolenaarea6561a2020-06-01 21:32:45 +0200110 \ searchcount(#{recompute: 1, maxcount: 0, timeout: 200}))
Bram Moolenaare8f5ec02020-06-01 17:28:35 +0200111 call assert_equal(
112 \ #{current: 271, exact_match: 1, total: 280, incomplete: 0, maxcount: 0},
Bram Moolenaarea6561a2020-06-01 21:32:45 +0200113 \ searchcount(#{recompute: 1, maxcount: 0, pos: [line('$')-2, 1, 0], timeout: 200}))
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200114
Bram Moolenaar984f0312019-05-24 13:11:47 +0200115 " Many matches
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200116 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 Moolenaardc6855a2019-05-18 19:26:29 +0200120 call cursor(1, 1)
121 let g:a = execute(':unsilent :norm! N')
Bram Moolenaar16b58ae2019-09-06 20:40:21 +0200122 let stat = 'W \[>99/>99\]'
Bram Moolenaardc6855a2019-05-18 19:26:29 +0200123 call assert_match(pat .. stat, g:a)
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200124
Bram Moolenaar984f0312019-05-24 13:11:47 +0200125 " right-left
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200126 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 Moolenaar984f0312019-05-24 13:11:47 +0200137 " right-left bottom
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200138 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 Moolenaar984f0312019-05-24 13:11:47 +0200148 " right-left back at top
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200149 if exists("+rightleft")
150 set rl
151 call cursor('$',1)
152 let pat = 'raboof/\s\+'
153 let g:a = execute(':unsilent :norm! n')
Bram Moolenaar16b58ae2019-09-06 20:40:21 +0200154 let stat = 'W \[20/1\]'
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200155 call assert_match(pat .. stat, g:a)
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200156 set norl
157 endif
158
Bram Moolenaar984f0312019-05-24 13:11:47 +0200159 " normal, back at bottom
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200160 call cursor(1,1)
161 let @/ = 'foobar'
162 let pat = '?foobar\s\+'
163 let g:a = execute(':unsilent :norm! N')
Bram Moolenaar16b58ae2019-09-06 20:40:21 +0200164 let stat = 'W \[20/20\]'
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200165 call assert_match(pat .. stat, g:a)
Bram Moolenaar16b58ae2019-09-06 20:40:21 +0200166 call assert_match('W \[20/20\]', Screenline(&lines))
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200167
Bram Moolenaar984f0312019-05-24 13:11:47 +0200168 " normal, no match
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200169 call cursor(1,1)
170 let @/ = 'zzzzzz'
171 let g:a = ''
172 try
173 let g:a = execute(':unsilent :norm! n')
174 catch /^Vim\%((\a\+)\)\=:E486/
175 let stat = ''
176 " error message is not redir'ed to g:a, it is empty
177 call assert_true(empty(g:a))
178 catch
179 call assert_false(1)
180 endtry
181
Bram Moolenaar8f46e4c2019-05-24 22:08:15 +0200182 " with count
183 call cursor(1, 1)
184 let @/ = 'fo*\(bar\?\)\?'
185 let g:a = execute(':unsilent :norm! 2n')
186 let stat = '\[3/50\]'
187 let pat = escape(@/, '()*?'). '\s\+'
188 call assert_match(pat .. stat, g:a)
189 let g:a = execute(':unsilent :norm! 2n')
190 let stat = '\[5/50\]'
191 call assert_match(pat .. stat, g:a)
192
193 " with offset
194 call cursor(1, 1)
195 call feedkeys("/fo*\\(bar\\?\\)\\?/+1\<cr>", 'tx')
196 let g:a = execute(':unsilent :norm! n')
197 let stat = '\[5/50\]'
198 let pat = escape(@/ .. '/+1', '()*?'). '\s\+'
199 call assert_match(pat .. stat, g:a)
200
Bram Moolenaar984f0312019-05-24 13:11:47 +0200201 " normal, n comes from a mapping
Bram Moolenaar9ce3fa82019-05-07 21:29:11 +0200202 " Need to move over more than 64 lines to trigger char_avail(.
203 nnoremap n nzv
204 call cursor(1,1)
205 call append(50, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10))
206 call setline(2, 'find this')
207 call setline(70, 'find this')
208 let @/ = 'find this'
209 let pat = '/find this\s\+'
210 let g:a = execute(':unsilent :norm n')
211 " g:a will contain several lines
212 let g:b = split(g:a, "\n")[-1]
213 let stat = '\[1/2\]'
214 call assert_match(pat .. stat, g:b)
215 unmap n
216
Bram Moolenaar984f0312019-05-24 13:11:47 +0200217 " normal, but silent
Bram Moolenaar9ce3fa82019-05-07 21:29:11 +0200218 call cursor(1,1)
219 let @/ = 'find this'
220 let pat = '/find this\s\+'
221 let g:a = execute(':norm! n')
222 let stat = '\[1/2\]'
223 call assert_notmatch(pat .. stat, g:a)
224
Bram Moolenaar19e8ac72019-09-03 22:23:38 +0200225 " normal, n comes from a silent mapping
226 " First test a normal mapping, then a silent mapping
227 call cursor(1,1)
228 nnoremap n n
229 let @/ = 'find this'
230 let pat = '/find this\s\+'
231 let g:a = execute(':unsilent :norm n')
232 let g:b = split(g:a, "\n")[-1]
233 let stat = '\[1/2\]'
234 call assert_match(pat .. stat, g:b)
235 nnoremap <silent> n n
236 call cursor(1,1)
237 let g:a = execute(':unsilent :norm n')
238 let g:b = split(g:a, "\n")[-1]
239 let stat = '\[1/2\]'
240 call assert_notmatch(pat .. stat, g:b)
241 call assert_match(stat, g:b)
Bram Moolenaar0f63ed32019-09-04 16:32:36 +0200242 " Test that the message is not truncated
243 " it would insert '...' into the output.
244 call assert_match('^\s\+' .. stat, g:b)
Bram Moolenaar19e8ac72019-09-03 22:23:38 +0200245 unmap n
246
Bram Moolenaare8f5ec02020-06-01 17:28:35 +0200247 " Time out
248 %delete _
249 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 100000))
250 call cursor(1, 1)
251 call assert_equal(1, searchcount(#{pattern: 'foo', maxcount: 0, timeout: 1}).incomplete)
252
Bram Moolenaar19e8ac72019-09-03 22:23:38 +0200253 " Clean up
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200254 set shortmess+=S
Bram Moolenaar19e8ac72019-09-03 22:23:38 +0200255 " close the window
Bram Moolenaar9dfa3132019-05-04 21:08:40 +0200256 bwipe!
257endfunc
Bram Moolenaar0f63ed32019-09-04 16:32:36 +0200258
Bram Moolenaar14681622020-06-03 22:57:39 +0200259func Test_searchcount_fails()
Yegappan Lakshmanan04c4c572022-08-30 19:48:24 +0100260 call assert_fails('echo searchcount("boo!")', 'E1206:')
Bram Moolenaar531be472020-09-23 22:38:05 +0200261 call assert_fails('echo searchcount({"timeout" : []})', 'E745:')
262 call assert_fails('echo searchcount({"maxcount" : []})', 'E745:')
263 call assert_fails('echo searchcount({"pattern" : []})', 'E730:')
264 call assert_fails('echo searchcount({"pos" : 1})', 'E475:')
265 call assert_fails('echo searchcount({"pos" : [1]})', 'E475:')
266 call assert_fails('echo searchcount({"pos" : [[], 2, 3]})', 'E745:')
267 call assert_fails('echo searchcount({"pos" : [1, [], 3]})', 'E745:')
268 call assert_fails('echo searchcount({"pos" : [1, 2, []]})', 'E745:')
Bram Moolenaar14681622020-06-03 22:57:39 +0200269endfunc
270
zeertzjqa7d36b72023-01-31 21:13:38 +0000271func Test_search_stat_narrow_screen()
272 " This used to crash Vim
273 let save_columns = &columns
274 try
275 let after =<< trim [CODE]
276 set laststatus=2
277 set columns=16
278 set shortmess-=S showcmd
279 call setline(1, 'abc')
280 call feedkeys("/abc\<CR>:quit!\<CR>")
281 autocmd VimLeavePre * call writefile(["done"], "Xdone")
282 [CODE]
283
284 if !RunVim([], after, '--clean')
285 return
286 endif
287 call assert_equal("done", readfile("Xdone")[0])
288 call delete('Xdone')
289 finally
290 let &columns = save_columns
291 endtry
292endfunc
293
Bram Moolenaar442a8532020-06-04 20:56:09 +0200294func Test_searchcount_in_statusline()
295 CheckScreendump
296
297 let lines =<< trim END
298 set shortmess-=S
299 call append(0, 'this is something')
300 function TestSearchCount() abort
301 let search_count = searchcount()
302 if !empty(search_count)
303 return '[' . search_count.current . '/' . search_count.total . ']'
304 else
305 return ''
306 endif
307 endfunction
308 set hlsearch
309 set laststatus=2 statusline+=%{TestSearchCount()}
310 END
Bram Moolenaar56564962022-10-10 22:39:42 +0100311 call writefile(lines, 'Xsearchstatusline', 'D')
Bram Moolenaar442a8532020-06-04 20:56:09 +0200312 let buf = RunVimInTerminal('-S Xsearchstatusline', #{rows: 10})
313 call TermWait(buf)
314 call term_sendkeys(buf, "/something")
315 call VerifyScreenDump(buf, 'Test_searchstat_4', {})
316
317 call term_sendkeys(buf, "\<Esc>")
318 call StopVimInTerminal(buf)
Bram Moolenaar442a8532020-06-04 20:56:09 +0200319endfunc
320
Bram Moolenaar6cb07262020-05-29 22:49:43 +0200321func Test_search_stat_foldopen()
322 CheckScreendump
323
324 let lines =<< trim END
325 set shortmess-=S
326 setl foldenable foldmethod=indent foldopen-=search
327 call append(0, ['if', "\tfoo", "\tfoo", 'endif'])
328 let @/ = 'foo'
329 call cursor(1,1)
330 norm n
331 END
Bram Moolenaar56564962022-10-10 22:39:42 +0100332 call writefile(lines, 'Xsearchstat1', 'D')
Bram Moolenaar6cb07262020-05-29 22:49:43 +0200333
334 let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10})
Bram Moolenaar6cb07262020-05-29 22:49:43 +0200335 call VerifyScreenDump(buf, 'Test_searchstat_3', {})
336
337 call term_sendkeys(buf, "n")
Bram Moolenaar6cb07262020-05-29 22:49:43 +0200338 call VerifyScreenDump(buf, 'Test_searchstat_3', {})
339
340 call term_sendkeys(buf, "n")
Bram Moolenaar6cb07262020-05-29 22:49:43 +0200341 call VerifyScreenDump(buf, 'Test_searchstat_3', {})
342
343 call StopVimInTerminal(buf)
Bram Moolenaar6cb07262020-05-29 22:49:43 +0200344endfunc
345
Bram Moolenaar0f63ed32019-09-04 16:32:36 +0200346func! Test_search_stat_screendump()
347 CheckScreendump
348
349 let lines =<< trim END
350 set shortmess-=S
351 " Append 50 lines with text to search for, "foobar" appears 20 times
352 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20))
353 call setline(2, 'find this')
354 call setline(70, 'find this')
355 nnoremap n n
356 let @/ = 'find this'
357 call cursor(1,1)
358 norm n
359 END
Bram Moolenaar56564962022-10-10 22:39:42 +0100360 call writefile(lines, 'Xsearchstat', 'D')
Bram Moolenaar0f63ed32019-09-04 16:32:36 +0200361 let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10})
Bram Moolenaar0f63ed32019-09-04 16:32:36 +0200362 call VerifyScreenDump(buf, 'Test_searchstat_1', {})
363
364 call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>")
365 call term_sendkeys(buf, "gg0n")
Bram Moolenaar0f63ed32019-09-04 16:32:36 +0200366 call VerifyScreenDump(buf, 'Test_searchstat_2', {})
367
368 call StopVimInTerminal(buf)
Bram Moolenaar0f63ed32019-09-04 16:32:36 +0200369endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200370
Bram Moolenaar0c711142021-11-12 10:30:04 +0000371func Test_search_stat_then_gd()
372 CheckScreendump
373
374 let lines =<< trim END
375 call setline(1, ['int cat;', 'int dog;', 'cat = dog;'])
376 set shortmess-=S
377 set hlsearch
378 END
Bram Moolenaar56564962022-10-10 22:39:42 +0100379 call writefile(lines, 'Xsearchstatgd', 'D')
Bram Moolenaar0c711142021-11-12 10:30:04 +0000380
381 let buf = RunVimInTerminal('-S Xsearchstatgd', #{rows: 10})
382 call term_sendkeys(buf, "/dog\<CR>")
Bram Moolenaar0c711142021-11-12 10:30:04 +0000383 call VerifyScreenDump(buf, 'Test_searchstatgd_1', {})
384
385 call term_sendkeys(buf, "G0gD")
Bram Moolenaar0c711142021-11-12 10:30:04 +0000386 call VerifyScreenDump(buf, 'Test_searchstatgd_2', {})
387
388 call StopVimInTerminal(buf)
Bram Moolenaar0c711142021-11-12 10:30:04 +0000389endfunc
390
Christian Brabandt6dd74242022-02-14 12:44:32 +0000391func Test_search_stat_and_incsearch()
392 CheckScreendump
393
394 let lines =<< trim END
395 call setline(1, ['abc--c', '--------abc', '--abc'])
396 set hlsearch
397 set incsearch
398 set bg=dark
399 set showtabline=2
400
401 function MyTabLine()
402 try
403 let a=searchcount(#{recompute: 1, maxcount: -1})
404 return a.current .. '/' .. a.total
405 catch
406 return ''
407 endtry
408 endfunction
409
410 set tabline=%!MyTabLine()
411 END
Bram Moolenaar56564962022-10-10 22:39:42 +0100412 call writefile(lines, 'Xsearchstat_inc', 'D')
Christian Brabandt6dd74242022-02-14 12:44:32 +0000413
414 let buf = RunVimInTerminal('-S Xsearchstat_inc', #{rows: 10})
415 call term_sendkeys(buf, "/abc")
416 call TermWait(buf)
417 call VerifyScreenDump(buf, 'Test_searchstat_inc_1', {})
418
419 call term_sendkeys(buf, "\<c-g>")
420 call TermWait(buf)
421 call VerifyScreenDump(buf, 'Test_searchstat_inc_2', {})
422
423 call term_sendkeys(buf, "\<c-g>")
424 call TermWait(buf)
425 call VerifyScreenDump(buf, 'Test_searchstat_inc_3', {})
426
427 call term_sendkeys(buf, "\<esc>:qa\<cr>")
428 call TermWait(buf)
429
430 call StopVimInTerminal(buf)
Christian Brabandt6dd74242022-02-14 12:44:32 +0000431endfunc
Bram Moolenaar0c711142021-11-12 10:30:04 +0000432
Christian Brabandt34a6a362023-05-06 19:20:20 +0100433func Test_search_stat_backwards()
434 CheckScreendump
435
436 let lines =<< trim END
437 set shm-=S
438 call setline(1, ['test', ''])
439 END
440 call writefile(lines, 'Xsearchstat_back', 'D')
441
442 let buf = RunVimInTerminal('-S Xsearchstat_back', #{rows: 10})
443 call term_sendkeys(buf, "*")
444 call TermWait(buf)
445 call VerifyScreenDump(buf, 'Test_searchstat_back_1', {})
446
447 call term_sendkeys(buf, "N")
448 call TermWait(buf)
449 call VerifyScreenDump(buf, 'Test_searchstat_back_2', {})
450
451 call term_sendkeys(buf, ":set shm+=S\<cr>N")
452 call TermWait(buf)
453 " shows "Search Hit Bottom.."
454 call VerifyScreenDump(buf, 'Test_searchstat_back_3', {})
455
456 call term_sendkeys(buf, "\<esc>:qa\<cr>")
457 call TermWait(buf)
458
459 call StopVimInTerminal(buf)
460endfunc
Bram Moolenaar0c711142021-11-12 10:30:04 +0000461
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200462" vim: shiftwidth=2 sts=2 expandtab