aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2016-11-22 06:52:51 +0900
committerJustin M. Keyes <justinkz@gmail.com>2016-12-09 17:46:14 +0100
commit7da7ff7c5c79dd36e053f5b5e86046838445bb8e (patch)
tree05a4a04e2e3878dbc1cd60897a42f7457de939c0 /src/nvim/testdir
parent880ce887ed1a7b7fcdbccbd59d45eb6b5537c67d (diff)
downloadrneovim-7da7ff7c5c79dd36e053f5b5e86046838445bb8e.tar.gz
rneovim-7da7ff7c5c79dd36e053f5b5e86046838445bb8e.tar.bz2
rneovim-7da7ff7c5c79dd36e053f5b5e86046838445bb8e.zip
vim-patch:7.4.1758, 7.4.1759, 7.4.1692 #5640
vim-patch:7.4.1758 Problem: Triggering CursorHoldI when in CTRL-X mode causes problems. Solution: Do not trigger CursorHoldI in CTRL-X mode. Add "!" flag to feedkeys() (test with that didn't work though). https://github.com/vim/vim/commit/245c41070c7f37d52be43cce0cb140bd3ade6c7e vim-patch:7.4.1759 Problem: When using feedkeys() in a timer the inserted characters are not used right away. Solution: Break the wait loop when characters have been added to typebuf. use this for testing CursorHoldI. https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8 vim-patch:7.4.1692 Problem: feedkeys('i', 'x') gets stuck, waits for a character to be typed. Solution: Behave like ":normal". (Yasuhiro Matsumoto)
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_autocmd.vim27
-rw-r--r--src/nvim/testdir/test_feedkeys.vim4
2 files changed, 31 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 12c984888e..d3e0981025 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -6,3 +6,30 @@ func Test_vim_did_enter()
" This script will never reach the main loop, can't check if v:vim_did_enter
" becomes one.
endfunc
+
+if !has('timers')
+ finish
+endif
+
+func ExitInsertMode(id)
+ call feedkeys("\<Esc>")
+endfunc
+
+func Test_cursorhold_insert()
+ let g:triggered = 0
+ au CursorHoldI * let g:triggered += 1
+ set updatetime=20
+ call timer_start(100, 'ExitInsertMode')
+ call feedkeys('a', 'x!')
+ call assert_equal(1, g:triggered)
+endfunc
+
+func Test_cursorhold_insert_ctrl_x()
+ let g:triggered = 0
+ au CursorHoldI * let g:triggered += 1
+ set updatetime=20
+ call timer_start(100, 'ExitInsertMode')
+ " CursorHoldI does not trigger after CTRL-X
+ call feedkeys("a\<C-X>", 'x!')
+ call assert_equal(0, g:triggered)
+endfunc
diff --git a/src/nvim/testdir/test_feedkeys.vim b/src/nvim/testdir/test_feedkeys.vim
index 33cd58949d..70500f2bb5 100644
--- a/src/nvim/testdir/test_feedkeys.vim
+++ b/src/nvim/testdir/test_feedkeys.vim
@@ -6,5 +6,9 @@ func Test_feedkeys_x_with_empty_string()
call assert_equal('', getline('.'))
call feedkeys('', 'x')
call assert_equal('foo', getline('.'))
+
+ " check it goes back to normal mode immediately.
+ call feedkeys('i', 'x')
+ call assert_equal('foo', getline('.'))
quit!
endfunc