mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
vim-patch:8.0.1259: search test can be flaky
Problem: Search test can be flaky.
Solution: Use WaitFor() instead of a delay. Make it possible to pass a
funcref to WaitFor() to avoid the need for global variables.
(James McCoy, closes vim/vim#2282)
13deab8d08
This commit is contained in:
@@ -133,7 +133,9 @@ func s:kill_server(cmd)
|
|||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Wait for up to a second for "expr" to become true.
|
" Wait for up to a second for "expr" to become true. "expr" can be a
|
||||||
|
" stringified expression to evaluate, or a funcref without arguments.
|
||||||
|
"
|
||||||
" A second argument can be used to specify a different timeout in msec.
|
" A second argument can be used to specify a different timeout in msec.
|
||||||
"
|
"
|
||||||
" Return time slept in milliseconds. With the +reltime feature this can be
|
" Return time slept in milliseconds. With the +reltime feature this can be
|
||||||
@@ -146,8 +148,13 @@ func WaitFor(expr, ...)
|
|||||||
else
|
else
|
||||||
let slept = 0
|
let slept = 0
|
||||||
endif
|
endif
|
||||||
|
if type(a:expr) == v:t_func
|
||||||
|
let Test = a:expr
|
||||||
|
else
|
||||||
|
let Test = {-> eval(a:expr) }
|
||||||
|
endif
|
||||||
for i in range(timeout / 10)
|
for i in range(timeout / 10)
|
||||||
if eval(a:expr)
|
if Test()
|
||||||
if has('reltime')
|
if has('reltime')
|
||||||
return float2nr(reltimefloat(reltime(start)) * 1000)
|
return float2nr(reltimefloat(reltime(start)) * 1000)
|
||||||
endif
|
endif
|
||||||
|
Reference in New Issue
Block a user