blob: caeeed6e53242398eb9cfc8135d92866dbcacea1 [file] [log] [blame]
Bram Moolenaar975b5272016-03-15 23:10:59 +01001" Test for timers
2
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02003source check.vim
4CheckFeature timers
Bram Moolenaar975b5272016-03-15 23:10:59 +01005
Bram Moolenaar3fffa972020-06-05 21:06:10 +02006source screendump.vim
Bram Moolenaar660b85e2017-09-30 14:26:58 +02007source shared.vim
Bram Moolenaar7a39dd72019-06-23 00:50:15 +02008source term_util.vim
Bram Moolenaar11aa62f2017-09-04 22:56:01 +02009
Bram Moolenaar975b5272016-03-15 23:10:59 +010010func MyHandler(timer)
Bram Moolenaarb73598e2016-08-07 18:22:53 +020011 let g:val += 1
Bram Moolenaar975b5272016-03-15 23:10:59 +010012endfunc
13
Bram Moolenaare3188e22016-05-31 21:13:04 +020014func MyHandlerWithLists(lists, timer)
15 let x = string(a:lists)
16endfunc
17
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +020018func Test_timer_oneshot()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020019 let g:val = 0
Bram Moolenaar975b5272016-03-15 23:10:59 +010020 let timer = timer_start(50, 'MyHandler')
Bram Moolenaarb73598e2016-08-07 18:22:53 +020021 let slept = WaitFor('g:val == 1')
22 call assert_equal(1, g:val)
Bram Moolenaarbc28e9f2019-12-18 20:10:23 +010023 if has('mac')
Bram Moolenaar818fed72019-12-25 15:47:14 +010024 " Mac on Travis can be very slow.
25 let limit = 180
Bram Moolenaarf267f8b2016-08-22 21:40:29 +020026 else
Bram Moolenaarbc28e9f2019-12-18 20:10:23 +010027 let limit = 100
28 endif
29 if has('reltime')
30 call assert_inrange(49, limit, slept)
31 else
32 call assert_inrange(20, limit, slept)
Bram Moolenaarf267f8b2016-08-22 21:40:29 +020033 endif
Bram Moolenaar975b5272016-03-15 23:10:59 +010034endfunc
35
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +020036func Test_timer_repeat_three()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020037 let g:val = 0
Bram Moolenaar975b5272016-03-15 23:10:59 +010038 let timer = timer_start(50, 'MyHandler', {'repeat': 3})
Bram Moolenaarb73598e2016-08-07 18:22:53 +020039 let slept = WaitFor('g:val == 3')
40 call assert_equal(3, g:val)
Bram Moolenaarf267f8b2016-08-22 21:40:29 +020041 if has('reltime')
Bram Moolenaarbc28e9f2019-12-18 20:10:23 +010042 if has('mac')
43 " Mac on Travis can be slow.
44 call assert_inrange(149, 400, slept)
45 else
46 call assert_inrange(149, 250, slept)
47 endif
Bram Moolenaarf267f8b2016-08-22 21:40:29 +020048 else
49 call assert_inrange(80, 200, slept)
50 endif
Bram Moolenaar975b5272016-03-15 23:10:59 +010051endfunc
52
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +020053func Test_timer_repeat_many()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020054 let g:val = 0
Bram Moolenaar975b5272016-03-15 23:10:59 +010055 let timer = timer_start(50, 'MyHandler', {'repeat': -1})
56 sleep 200m
57 call timer_stop(timer)
Bram Moolenaarbc28e9f2019-12-18 20:10:23 +010058 " Mac on Travis can be slow.
59 if has('mac')
60 call assert_inrange(1, 5, g:val)
61 else
62 call assert_inrange(2, 5, g:val)
63 endif
Bram Moolenaar975b5272016-03-15 23:10:59 +010064endfunc
Bram Moolenaar92e35ef2016-03-26 18:20:41 +010065
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +020066func Test_timer_with_partial_callback()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020067 let g:val = 0
Bram Moolenaar26fe0d52016-09-10 14:27:30 +020068 let meow = {'one': 1}
69 function meow.bite(...)
70 let g:val += self.one
Bram Moolenaar92e35ef2016-03-26 18:20:41 +010071 endfunction
72
Bram Moolenaar26fe0d52016-09-10 14:27:30 +020073 call timer_start(50, meow.bite)
Bram Moolenaarb73598e2016-08-07 18:22:53 +020074 let slept = WaitFor('g:val == 1')
75 call assert_equal(1, g:val)
Bram Moolenaarf267f8b2016-08-22 21:40:29 +020076 if has('reltime')
Bram Moolenaar5c463a22019-12-27 17:14:33 +010077 " Mac on Travis can be slow.
78 if has('mac')
79 call assert_inrange(49, 180, slept)
80 else
81 call assert_inrange(49, 130, slept)
82 endif
Bram Moolenaarf267f8b2016-08-22 21:40:29 +020083 else
84 call assert_inrange(20, 100, slept)
85 endif
Bram Moolenaar92e35ef2016-03-26 18:20:41 +010086endfunc
Bram Moolenaare3188e22016-05-31 21:13:04 +020087
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +020088func Test_timer_retain_partial()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020089 call timer_start(50, function('MyHandlerWithLists', [['a']]))
Bram Moolenaare3188e22016-05-31 21:13:04 +020090 call test_garbagecollect_now()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020091 sleep 100m
Bram Moolenaare3188e22016-05-31 21:13:04 +020092endfunc
Bram Moolenaarb73598e2016-08-07 18:22:53 +020093
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +020094func Test_timer_info()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020095 let id = timer_start(1000, 'MyHandler')
Bram Moolenaarf92e58c2019-09-08 21:51:41 +020096 let info = id->timer_info()
Bram Moolenaarb73598e2016-08-07 18:22:53 +020097 call assert_equal(id, info[0]['id'])
98 call assert_equal(1000, info[0]['time'])
99 call assert_true(info[0]['remaining'] > 500)
100 call assert_true(info[0]['remaining'] <= 1000)
101 call assert_equal(1, info[0]['repeat'])
102 call assert_equal("function('MyHandler')", string(info[0]['callback']))
103
104 let found = 0
105 for info in timer_info()
106 if info['id'] == id
107 let found += 1
108 endif
109 endfor
110 call assert_equal(1, found)
111
112 call timer_stop(id)
113 call assert_equal([], timer_info(id))
Bram Moolenaare20b9ec2020-02-03 21:40:04 +0100114
115 call assert_fails('call timer_info("abc")', 'E39:')
Bram Moolenaarb73598e2016-08-07 18:22:53 +0200116endfunc
117
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200118func Test_timer_stopall()
Bram Moolenaarb73598e2016-08-07 18:22:53 +0200119 let id1 = timer_start(1000, 'MyHandler')
120 let id2 = timer_start(2000, 'MyHandler')
121 let info = timer_info()
122 call assert_equal(2, len(info))
123
124 call timer_stopall()
125 let info = timer_info()
126 call assert_equal(0, len(info))
127endfunc
128
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200129func Test_timer_paused()
Bram Moolenaarb73598e2016-08-07 18:22:53 +0200130 let g:val = 0
131
132 let id = timer_start(50, 'MyHandler')
133 let info = timer_info(id)
134 call assert_equal(0, info[0]['paused'])
135
Bram Moolenaarf92e58c2019-09-08 21:51:41 +0200136 eval id->timer_pause(1)
Bram Moolenaarb73598e2016-08-07 18:22:53 +0200137 let info = timer_info(id)
138 call assert_equal(1, info[0]['paused'])
139 sleep 100m
140 call assert_equal(0, g:val)
141
142 call timer_pause(id, 0)
143 let info = timer_info(id)
144 call assert_equal(0, info[0]['paused'])
145
146 let slept = WaitFor('g:val == 1')
147 call assert_equal(1, g:val)
Bram Moolenaarf267f8b2016-08-22 21:40:29 +0200148 if has('reltime')
Bram Moolenaara47ebdb2017-12-23 18:41:35 +0100149 if has('mac')
150 " The travis Mac machines appear to be very busy.
Bram Moolenaarbc28e9f2019-12-18 20:10:23 +0100151 call assert_inrange(0, 90, slept)
Bram Moolenaara47ebdb2017-12-23 18:41:35 +0100152 else
153 call assert_inrange(0, 30, slept)
154 endif
Bram Moolenaarf267f8b2016-08-22 21:40:29 +0200155 else
156 call assert_inrange(0, 10, slept)
157 endif
Bram Moolenaare20b9ec2020-02-03 21:40:04 +0100158
159 call assert_fails('call timer_pause("abc", 1)', 'E39:')
Bram Moolenaarb73598e2016-08-07 18:22:53 +0200160endfunc
161
Bram Moolenaar417ccd72016-09-01 21:26:20 +0200162func StopMyself(timer)
163 let g:called += 1
164 if g:called == 2
165 call timer_stop(a:timer)
166 endif
167endfunc
168
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200169func Test_timer_delete_myself()
Bram Moolenaar417ccd72016-09-01 21:26:20 +0200170 let g:called = 0
171 let t = timer_start(10, 'StopMyself', {'repeat': -1})
Bram Moolenaar0e9d1ae2018-04-30 14:28:24 +0200172 call WaitForAssert({-> assert_equal(2, g:called)})
Bram Moolenaar417ccd72016-09-01 21:26:20 +0200173 call assert_equal(2, g:called)
174 call assert_equal([], timer_info(t))
175endfunc
176
Bram Moolenaar75537a92016-09-05 22:45:28 +0200177func StopTimer1(timer)
Bram Moolenaarf92e58c2019-09-08 21:51:41 +0200178 let g:timer2 = 10->timer_start('StopTimer2')
Bram Moolenaar75537a92016-09-05 22:45:28 +0200179 " avoid maxfuncdepth error
180 call timer_pause(g:timer1, 1)
Bram Moolenaar413c04e2019-08-16 22:29:18 +0200181 sleep 20m
Bram Moolenaar75537a92016-09-05 22:45:28 +0200182endfunc
183
184func StopTimer2(timer)
185 call timer_stop(g:timer1)
186endfunc
187
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200188func Test_timer_stop_in_callback()
Bram Moolenaar427dddf2019-08-16 21:22:41 +0200189 call assert_equal(0, len(timer_info()))
Bram Moolenaar75537a92016-09-05 22:45:28 +0200190 let g:timer1 = timer_start(10, 'StopTimer1')
Bram Moolenaar315244d2019-08-17 13:18:16 +0200191 let slept = 0
192 for i in range(10)
193 if len(timer_info()) == 0
194 break
195 endif
196 sleep 10m
197 let slept += 10
198 endfor
199 " This should take only 30 msec, but on Mac it's often longer
200 call assert_inrange(0, 50, slept)
Bram Moolenaar75537a92016-09-05 22:45:28 +0200201endfunc
202
203func StopTimerAll(timer)
204 call timer_stopall()
205endfunc
206
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200207func Test_timer_stop_all_in_callback()
Bram Moolenaar427dddf2019-08-16 21:22:41 +0200208 call assert_equal(0, len(timer_info()))
209 call timer_start(10, 'StopTimerAll')
210 call assert_equal(1, len(timer_info()))
211 let slept = 0
212 for i in range(10)
213 if len(timer_info()) == 0
214 break
215 endif
216 sleep 10m
217 let slept += 10
218 endfor
219 call assert_inrange(0, 30, slept)
Bram Moolenaar75537a92016-09-05 22:45:28 +0200220endfunc
221
Bram Moolenaar1e8e1452017-06-24 16:03:06 +0200222func FeedkeysCb(timer)
223 call feedkeys("hello\<CR>", 'nt')
224endfunc
225
226func InputCb(timer)
227 call timer_start(10, 'FeedkeysCb')
228 let g:val = input('?')
229 call Resume()
230endfunc
231
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200232func Test_timer_input_in_timer()
Bram Moolenaar1e8e1452017-06-24 16:03:06 +0200233 let g:val = ''
234 call timer_start(10, 'InputCb')
235 call Standby(1000)
236 call assert_equal('hello', g:val)
237endfunc
Bram Moolenaar75537a92016-09-05 22:45:28 +0200238
Bram Moolenaarc577d812017-07-08 22:37:34 +0200239func FuncWithError(timer)
240 let g:call_count += 1
241 if g:call_count == 4
242 return
243 endif
244 doesnotexist
245endfunc
246
247func Test_timer_errors()
248 let g:call_count = 0
249 let timer = timer_start(10, 'FuncWithError', {'repeat': -1})
250 " Timer will be stopped after failing 3 out of 3 times.
Bram Moolenaar0e9d1ae2018-04-30 14:28:24 +0200251 call WaitForAssert({-> assert_equal(3, g:call_count)})
Bram Moolenaarc577d812017-07-08 22:37:34 +0200252 sleep 50m
253 call assert_equal(3, g:call_count)
Bram Moolenaare20b9ec2020-02-03 21:40:04 +0100254
255 call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E475:')
256 call assert_fails('call timer_start(100, [])', 'E921:')
257 call assert_fails('call timer_stop("abc")', 'E39:')
Bram Moolenaarc577d812017-07-08 22:37:34 +0200258endfunc
259
Bram Moolenaare723c422017-09-06 23:40:10 +0200260func FuncWithCaughtError(timer)
261 let g:call_count += 1
262 try
263 doesnotexist
264 catch
265 " nop
266 endtry
267endfunc
268
269func Test_timer_catch_error()
270 let g:call_count = 0
271 let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4})
272 " Timer will not be stopped.
Bram Moolenaar0e9d1ae2018-04-30 14:28:24 +0200273 call WaitForAssert({-> assert_equal(4, g:call_count)})
Bram Moolenaare723c422017-09-06 23:40:10 +0200274 sleep 50m
275 call assert_equal(4, g:call_count)
276endfunc
277
Bram Moolenaar5e80de32017-09-03 15:48:12 +0200278func FeedAndPeek(timer)
279 call test_feedinput('a')
280 call getchar(1)
281endfunc
282
283func Interrupt(timer)
Bram Moolenaarce90e362019-09-08 18:58:44 +0200284 eval "\<C-C>"->test_feedinput()
Bram Moolenaar5e80de32017-09-03 15:48:12 +0200285endfunc
286
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200287func Test_timer_peek_and_get_char()
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200288 CheckUnix
289 CheckGui
290
Bram Moolenaar5e80de32017-09-03 15:48:12 +0200291 call timer_start(0, 'FeedAndPeek')
292 let intr = timer_start(100, 'Interrupt')
293 let c = getchar()
294 call assert_equal(char2nr('a'), c)
Bram Moolenaarf92e58c2019-09-08 21:51:41 +0200295 eval intr->timer_stop()
Bram Moolenaar5e80de32017-09-03 15:48:12 +0200296endfunc
Bram Moolenaarc577d812017-07-08 22:37:34 +0200297
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200298func Test_timer_getchar_zero()
Bram Moolenaar8d4ce562019-01-30 22:01:40 +0100299 if has('win32') && !has('gui_running')
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200300 throw 'Skipped: cannot get low-level input'
Bram Moolenaarcb908a82019-01-28 23:20:04 +0100301 endif
Bram Moolenaar5feabe02020-01-30 18:24:53 +0100302 CheckFunction reltimefloat
Bram Moolenaarcb908a82019-01-28 23:20:04 +0100303
Bram Moolenaar50948e42019-01-29 20:36:56 +0100304 " Measure the elapsed time to avoid a hang when it fails.
305 let start = reltime()
Bram Moolenaar8d4ce562019-01-30 22:01:40 +0100306 let id = timer_start(20, {-> feedkeys('x', 'L')})
Bram Moolenaar12dfc9e2019-01-28 22:32:58 +0100307 let c = 0
Bram Moolenaar50948e42019-01-29 20:36:56 +0100308 while c == 0 && reltimefloat(reltime(start)) < 0.2
Bram Moolenaar12dfc9e2019-01-28 22:32:58 +0100309 let c = getchar(0)
310 sleep 10m
311 endwhile
312 call assert_equal('x', nr2char(c))
Bram Moolenaarcb908a82019-01-28 23:20:04 +0100313 call timer_stop(id)
Bram Moolenaar12dfc9e2019-01-28 22:32:58 +0100314endfunc
315
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200316func Test_timer_ex_mode()
Bram Moolenaarf5291f32017-09-14 22:55:37 +0200317 " Function with an empty line.
318 func Foo(...)
319
320 endfunc
Bram Moolenaarcb908a82019-01-28 23:20:04 +0100321 let timer = timer_start(40, function('g:Foo'), {'repeat':-1})
Bram Moolenaarf5291f32017-09-14 22:55:37 +0200322 " This used to throw error E749.
323 exe "normal Qsleep 100m\rvi\r"
324 call timer_stop(timer)
325endfunc
326
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200327func Test_timer_restore_count()
Bram Moolenaar494e9062020-05-31 21:28:02 +0200328 CheckRunVimInTerminal
Bram Moolenaarb0f42ba2018-05-12 15:38:26 +0200329 " Check that v:count is saved and restored, not changed by a timer.
330 call writefile([
331 \ 'nnoremap <expr><silent> L v:count ? v:count . "l" : "l"',
332 \ 'func Doit(id)',
333 \ ' normal 3j',
334 \ 'endfunc',
335 \ 'call timer_start(100, "Doit")',
336 \ ], 'Xtrcscript')
337 call writefile([
338 \ '1-1234',
339 \ '2-1234',
340 \ '3-1234',
341 \ ], 'Xtrctext')
342 let buf = RunVimInTerminal('-S Xtrcscript Xtrctext', {})
343
344 " Wait for the timer to move the cursor to the third line.
345 call WaitForAssert({-> assert_equal(3, term_getcursor(buf)[0])})
346 call assert_equal(1, term_getcursor(buf)[1])
347 " Now check that v:count has not been set to 3
348 call term_sendkeys(buf, 'L')
349 call WaitForAssert({-> assert_equal(2, term_getcursor(buf)[1])})
350
351 call StopVimInTerminal(buf)
352 call delete('Xtrcscript')
353 call delete('Xtrctext')
354endfunc
355
Bram Moolenaaradc67142019-06-22 01:40:42 +0200356" Test that the garbage collector isn't triggered if a timer callback invokes
357" vgetc().
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200358func Test_timer_nocatch_garbage_collect()
Bram Moolenaaradc67142019-06-22 01:40:42 +0200359 " 'uptimetime. must be bigger than the timer timeout
360 set ut=200
361 call test_garbagecollect_soon()
362 call test_override('no_wait_return', 0)
363 func CauseAnError(id)
364 " This will show an error and wait for Enter.
365 let a = {'foo', 'bar'}
366 endfunc
367 func FeedChar(id)
368 call feedkeys('x', 't')
369 endfunc
370 call timer_start(300, 'FeedChar')
371 call timer_start(100, 'CauseAnError')
372 let x = getchar()
373
374 set ut&
375 call test_override('no_wait_return', 1)
376 delfunc CauseAnError
377 delfunc FeedChar
378endfunc
379
Bram Moolenaar9a2fddc2019-08-16 11:26:06 +0200380func Test_timer_error_in_timer_callback()
Bram Moolenaar0d702022019-07-04 14:20:41 +0200381 if !has('terminal') || (has('win32') && has('gui_running'))
Bram Moolenaar7d491c42019-06-25 06:28:02 +0200382 throw 'Skipped: cannot run Vim in a terminal window'
383 endif
384
385 let lines =<< trim [CODE]
386 func Func(timer)
387 " fail to create list
388 let x = [
389 endfunc
390 set updatetime=50
391 call timer_start(1, 'Func')
392 [CODE]
393 call writefile(lines, 'Xtest.vim')
394
Bram Moolenaar0d702022019-07-04 14:20:41 +0200395 let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8})
Bram Moolenaar7d491c42019-06-25 06:28:02 +0200396 let job = term_getjob(buf)
397 call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))})
398
399 " GC must not run during timer callback, which can make Vim crash.
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200400 call TermWait(buf, 50)
Bram Moolenaar7d491c42019-06-25 06:28:02 +0200401 call term_sendkeys(buf, "\<CR>")
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200402 call TermWait(buf, 50)
Bram Moolenaar7d491c42019-06-25 06:28:02 +0200403 call assert_equal('run', job_status(job))
404
405 call term_sendkeys(buf, ":qall!\<CR>")
406 call WaitFor({-> job_status(job) ==# 'dead'})
407 if has('unix')
408 call assert_equal('', job_info(job).termsig)
409 endif
410
411 call delete('Xtest.vim')
412 exe buf .. 'bwipe!'
413endfunc
414
Bram Moolenaare20b9ec2020-02-03 21:40:04 +0100415" Test for garbage collection when a timer is still running
416func Test_timer_garbage_collect()
417 let timer = timer_start(1000, function('MyHandler'), {'repeat' : 10})
418 call test_garbagecollect_now()
419 let l = timer_info(timer)
420 call assert_equal(function('MyHandler'), l[0].callback)
421 call timer_stop(timer)
422endfunc
423
Bram Moolenaar14e579092020-03-07 16:59:25 +0100424func Test_timer_invalid_callback()
Bram Moolenaare2e40752020-09-04 21:18:46 +0200425 call assert_fails('call timer_start(0, "0")', 'E921:')
Bram Moolenaar14e579092020-03-07 16:59:25 +0100426endfunc
427
Bram Moolenaar3fffa972020-06-05 21:06:10 +0200428func Test_timer_changing_function_list()
429 CheckRunVimInTerminal
430
431 " Create a large number of functions. Should get the "more" prompt.
432 " The typing "G" triggers the timer, which changes the function table.
433 let lines =<< trim END
434 for func in map(range(1,99), "'Func' .. v:val")
435 exe "func " .. func .. "()"
436 endfunc
437 endfor
438 au CmdlineLeave : call timer_start(0, {-> 0})
439 END
440 call writefile(lines, 'XTest_timerchange')
441 let buf = RunVimInTerminal('-S XTest_timerchange', #{rows: 10})
442 call term_sendkeys(buf, ":fu\<CR>")
443 call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 10))})
444 call term_sendkeys(buf, "G")
Bram Moolenaare2e40752020-09-04 21:18:46 +0200445 call WaitForAssert({-> assert_match('E454:', term_getline(buf, 9))})
Bram Moolenaar3fffa972020-06-05 21:06:10 +0200446 call term_sendkeys(buf, "\<Esc>")
447
448 call StopVimInTerminal(buf)
449 call delete('XTest_timerchange')
450endfunc
451
Bram Moolenaar9f284162021-04-22 21:39:30 +0200452func Test_timer_outputting_message()
453 CheckRunVimInTerminal
454
455 let lines =<< trim END
456 vim9script
457 setline(1, 'some text')
458 set showcmd ut=2000 cmdheight=1
459 timer_start(0, (_) => {
460 echon repeat('x', &columns - 11)
461 })
462 END
463 call writefile(lines, 'XTest_timermessage')
464 let buf = RunVimInTerminal('-S XTest_timermessage', #{rows: 6})
465 call term_sendkeys(buf, "l")
466 call term_wait(buf)
467 " should not get a hit-enter prompt
468 call WaitForAssert({-> assert_match('xxxxxxxxxxx', term_getline(buf, 6))})
469
470 call StopVimInTerminal(buf)
471 call delete('XTest_timermessage')
472endfunc
473
Bram Moolenaar9e4d8212016-08-18 23:04:48 +0200474" vim: shiftwidth=2 sts=2 expandtab