forked from aniani/vim
patch 8.2.5131: timeout implementation is not optimal
Problem: Timeout implementation is not optimal.
Solution: Further improvements for timeouts. Add a test for searchpair()
timeout. (partly by Paul Ollis)
This commit is contained in:
@@ -37,7 +37,7 @@ endfunc
|
||||
func Test_hlsearch_hangs()
|
||||
CheckFunction reltimefloat
|
||||
|
||||
" So, it turns out the Windows 7 implements TimerQueue timers differently
|
||||
" So, it turns out that Windows 7 implements TimerQueue timers differently
|
||||
" and they can expire *before* the requested time has elapsed. So allow for
|
||||
" the timeout occurring after 80 ms (5 * 16 (the typical clock tick)).
|
||||
if has("win32")
|
||||
|
||||
@@ -355,6 +355,37 @@ func Test_searchpair_timeout()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func SearchpairSkip()
|
||||
let id = synID(line('.'), col('.'), 0)
|
||||
let attr = synIDattr(id, 'name')
|
||||
return attr !~ 'comment'
|
||||
endfunc
|
||||
|
||||
func Test_searchpair_timeout_with_skip()
|
||||
let g:test_is_flaky = 1
|
||||
|
||||
edit ../evalfunc.c
|
||||
if has('win32')
|
||||
" Windows timeouts are rather coarse grained, about 16ms.
|
||||
let ms = 20
|
||||
let min_time = 0.016
|
||||
let max_time = min_time * 10.0
|
||||
else
|
||||
let ms = 1
|
||||
let min_time = 0.001
|
||||
let max_time = min_time * 10.0
|
||||
if GetVimCommand() =~ 'valgrind.*--log-file='
|
||||
let max_time += 0.04 " this can be slow with valgrind
|
||||
endif
|
||||
endif
|
||||
let start = reltime()
|
||||
let found = searchpair('(', '', ')', 'crnm', 'SearchpairSkip()', 0, ms)
|
||||
let elapsed = reltimefloat(reltime(start))
|
||||
call assert_inrange(min_time, max_time, elapsed)
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_searchpairpos()
|
||||
new
|
||||
call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])
|
||||
|
||||
Reference in New Issue
Block a user