summaryrefslogtreecommitdiffstats
path: root/src/testdir/shared.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-10-27 20:00:07 +0200
committerBram Moolenaar <Bram@vim.org>2016-10-27 20:00:07 +0200
commit01688ad545ff0809ddad5c8fa6b149dc5d67312b (patch)
treef588850e3798caf6ddef56772a58903d8b3ab4eb /src/testdir/shared.vim
parent2f97912800e86a296c001832bbbf2fc425f1e533 (diff)
patch 8.0.0050v8.0.0050
Problem: An exiting job is detected with a large latency. Solution: Check for pending job more often. (Ozaki Kiichi) Change the double loop in mch_inchar() into one.
Diffstat (limited to 'src/testdir/shared.vim')
-rw-r--r--src/testdir/shared.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim
index 24b05bec6a..45a2ea496d 100644
--- a/src/testdir/shared.vim
+++ b/src/testdir/shared.vim
@@ -136,6 +136,34 @@ func WaitFor(expr)
return 1000
endfunc
+" Wait for up to a given milliseconds.
+" With the +timers feature this waits for key-input by getchar(), Resume()
+" feeds key-input and resumes process. Return time waited in milliseconds.
+" Without +timers it uses simply :sleep.
+func Standby(msec)
+ if has('timers')
+ let start = reltime()
+ let g:_standby_timer = timer_start(a:msec, function('s:feedkeys'))
+ call getchar()
+ return float2nr(reltimefloat(reltime(start)) * 1000)
+ else
+ execute 'sleep ' a:msec . 'm'
+ return a:msec
+ endif
+endfunc
+
+func Resume()
+ if exists('g:_standby_timer')
+ call timer_stop(g:_standby_timer)
+ call s:feedkeys(0)
+ unlet g:_standby_timer
+ endif
+endfunc
+
+func s:feedkeys(timer)
+ call feedkeys('x', 'nt')
+endfunc
+
" Run Vim, using the "vimcmd" file and "-u NORC".
" "before" is a list of Vim commands to be executed before loading plugins.
" "after" is a list of Vim commands to be executed after loading plugins.