summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_autocmd.vim
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2024-06-20 22:05:16 +0200
committerChristian Brabandt <cb@256bit.org>2024-06-20 22:05:16 +0200
commitd09521476f41dd8dbddb25b7acd0b299f9bf94d3 (patch)
treee0228de6da48415951831957367a96b7aff07636 /src/testdir/test_autocmd.vim
parentbeb02ed674bc61f179c4ff71e93bdeeb44fe9c4e (diff)
patch 9.1.0507: hard to detect cursor movement in the command linev9.1.0507
Problem: hard to detect cursor movement in the command line Solution: Add the CursorMovedC autocommand (Shougo Matsushita) closes: #15040 Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir/test_autocmd.vim')
-rw-r--r--src/testdir/test_autocmd.vim15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index c9f257a87c..faa0f9771c 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -2096,6 +2096,21 @@ func Test_Cmdline()
au! CmdlineEnter
au! CmdlineLeave
let &shellslash = save_shellslash
+
+ au! CursorMovedC : let g:pos = getcmdpos()
+ let g:pos = 0
+ call feedkeys(":hello\<Left>\<ESC>", 'xt')
+ call assert_equal(5, g:pos)
+ call feedkeys(":12345678\<C-R>=setcmdpos(3)\<CR>\<ESC>", 'xt')
+ call assert_equal(3, g:pos)
+ au! CursorMovedC
+
+ " CursorMovedC changes the cursor position.
+ au! CursorMovedC : let g:pos = getcmdpos() | call setcmdpos(getcmdpos()-1)
+ let g:pos = 0
+ call feedkeys(":hello\<Left>\<ESC>", 'xt')
+ call assert_equal(5, g:pos)
+ au! CursorMovedC
endfunc
" Test for BufWritePre autocommand that deletes or unloads the buffer.