diff 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
line wrap: on
line diff
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -328,7 +328,31 @@ func Test_searchpair()
   call assert_equal(3, searchpair('\<if\>', '\<else\>', '\<endif\>', 'W'))
   call assert_equal([0, 3, 3, 0], getpos('.'))
 
-  q!
+  bwipe!
+endfunc
+
+func Test_searchpair_timeout()
+  CheckFeature reltime
+
+  func Waitabit()
+    sleep 20m
+    return 1  " skip match
+  endfunc
+
+  new
+  call setline(1, range(100))
+  call setline(1, "(start here")
+  call setline(100, "end here)")
+  let starttime = reltime()
+
+  " A timeout of 100 msec should happen after about five times of 20 msec wait
+  " in Waitabit().  When the timeout applies to each search the elapsed time
+  " will be much longer.
+  call assert_equal(0, searchpair('(', '\d', ')', '', "Waitabit()", 0, 100))
+  let elapsed = reltime(starttime)->reltimefloat()
+  call assert_inrange(0.09, 0.300, elapsed)
+
+  bwipe!
 endfunc
 
 func Test_searchpairpos()