Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 15659:8513d9864f7e v8.1.0837
patch 8.1.0837: timer interrupting cursorhold and mapping not tested
commit https://github.com/vim/vim/commit/26d982185e21398738a9c688429c0a1840d7c9c3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 27 22:32:55 2019 +0100
patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Problem: Timer interrupting cursorhold and mapping not tested.
Solution: Add tests with timers. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/3871)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Jan 2019 22:45:05 +0100 |
parents | 536fca2cee19 |
children | cb501b3c9fb5 |
comparison
equal
deleted
inserted
replaced
15658:baf0958cbef4 | 15659:8513d9864f7e |
---|---|
30 au CursorHoldI * let g:triggered += 1 | 30 au CursorHoldI * let g:triggered += 1 |
31 set updatetime=20 | 31 set updatetime=20 |
32 call timer_start(100, 'ExitInsertMode') | 32 call timer_start(100, 'ExitInsertMode') |
33 call feedkeys('a', 'x!') | 33 call feedkeys('a', 'x!') |
34 call assert_equal(1, g:triggered) | 34 call assert_equal(1, g:triggered) |
35 unlet g:triggered | |
36 au! CursorHoldI | |
37 set updatetime& | |
38 endfunc | |
39 | |
40 func Test_cursorhold_insert_with_timer_interrupt() | |
41 if !has('job') | |
42 return | |
43 endif | |
44 " Need to move the cursor. | |
45 call feedkeys("ggG", "xt") | |
46 | |
47 " Confirm the timer invoked in exit_cb of the job doesn't disturb | |
48 " CursorHoldI event. | |
49 let g:triggered = 0 | |
50 au CursorHoldI * let g:triggered += 1 | |
51 set updatetime=500 | |
52 call job_start(has('win32') ? 'cmd /c echo:' : 'echo', | |
53 \ {'exit_cb': {j, s -> timer_start(1000, 'ExitInsertMode')}}) | |
54 call feedkeys('a', 'x!') | |
55 call assert_equal(1, g:triggered) | |
56 unlet g:triggered | |
35 au! CursorHoldI | 57 au! CursorHoldI |
36 set updatetime& | 58 set updatetime& |
37 endfunc | 59 endfunc |
38 | 60 |
39 func Test_cursorhold_insert_ctrl_x() | 61 func Test_cursorhold_insert_ctrl_x() |
42 set updatetime=20 | 64 set updatetime=20 |
43 call timer_start(100, 'ExitInsertMode') | 65 call timer_start(100, 'ExitInsertMode') |
44 " CursorHoldI does not trigger after CTRL-X | 66 " CursorHoldI does not trigger after CTRL-X |
45 call feedkeys("a\<C-X>", 'x!') | 67 call feedkeys("a\<C-X>", 'x!') |
46 call assert_equal(0, g:triggered) | 68 call assert_equal(0, g:triggered) |
69 unlet g:triggered | |
47 au! CursorHoldI | 70 au! CursorHoldI |
48 set updatetime& | 71 set updatetime& |
49 endfunc | 72 endfunc |
50 endif | 73 endif |
51 | 74 |
450 let g:opt = [expected, actual] | 473 let g:opt = [expected, actual] |
451 "call assert_equal(expected, actual) | 474 "call assert_equal(expected, actual) |
452 endfunc | 475 endfunc |
453 | 476 |
454 func Test_OptionSet() | 477 func Test_OptionSet() |
455 if !has("eval") || !has("autocmd") || !exists("+autochdir") | 478 if !has("eval") || !exists("+autochdir") |
456 return | 479 return |
457 endif | 480 endif |
458 | 481 |
459 badd test_autocmd.vim | 482 badd test_autocmd.vim |
460 | 483 |
593 delfunc! AutoCommandOptionSet | 616 delfunc! AutoCommandOptionSet |
594 endfunc | 617 endfunc |
595 | 618 |
596 func Test_OptionSet_diffmode() | 619 func Test_OptionSet_diffmode() |
597 call test_override('starting', 1) | 620 call test_override('starting', 1) |
598 " 18: Changing an option when enetering diff mode | 621 " 18: Changing an option when entering diff mode |
599 new | 622 new |
600 au OptionSet diff :let &l:cul=v:option_new | 623 au OptionSet diff :let &l:cul=v:option_new |
601 | 624 |
602 call setline(1, ['buffer 1', 'line2', 'line3', 'line4']) | 625 call setline(1, ['buffer 1', 'line2', 'line3', 'line4']) |
603 call assert_equal(0, &l:cul) | 626 call assert_equal(0, &l:cul) |