comparison src/testdir/test_search.vim @ 29189:d1e263ecf634 v8.2.5114

patch 8.2.5114: time limit on searchpair() does not work properly Commit: https://github.com/vim/vim/commit/5ea38d1e7fd597ffde13b292d43e12747f20e97f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 16 21:20:48 2022 +0100 patch 8.2.5114: time limit on searchpair() does not work properly Problem: Time limit on searchpair() does not work properly. Solution: Set the time limit once instead of for each regexp. (closes https://github.com/vim/vim/issues/10562)
author Bram Moolenaar <Bram@vim.org>
date Thu, 16 Jun 2022 22:30:03 +0200
parents b90bca860b5a
children 0af5fe160e4e
comparison
equal deleted inserted replaced
29188:f96e0bc4494b 29189:d1e263ecf634
326 call assert_equal([0, 5, 1, 0], getpos('.')) 326 call assert_equal([0, 5, 1, 0], getpos('.'))
327 /\<if 2 327 /\<if 2
328 call assert_equal(3, searchpair('\<if\>', '\<else\>', '\<endif\>', 'W')) 328 call assert_equal(3, searchpair('\<if\>', '\<else\>', '\<endif\>', 'W'))
329 call assert_equal([0, 3, 3, 0], getpos('.')) 329 call assert_equal([0, 3, 3, 0], getpos('.'))
330 330
331 q! 331 bwipe!
332 endfunc
333
334 func Test_searchpair_timeout()
335 CheckFeature reltime
336
337 func Waitabit()
338 sleep 20m
339 return 1 " skip match
340 endfunc
341
342 new
343 call setline(1, range(100))
344 call setline(1, "(start here")
345 call setline(100, "end here)")
346 let starttime = reltime()
347
348 " A timeout of 100 msec should happen after about five times of 20 msec wait
349 " in Waitabit(). When the timeout applies to each search the elapsed time
350 " will be much longer.
351 call assert_equal(0, searchpair('(', '\d', ')', '', "Waitabit()", 0, 100))
352 let elapsed = reltime(starttime)->reltimefloat()
353 call assert_inrange(0.09, 0.300, elapsed)
354
355 bwipe!
332 endfunc 356 endfunc
333 357
334 func Test_searchpairpos() 358 func Test_searchpairpos()
335 new 359 new
336 call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]']) 360 call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])