diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-06-21 14:11:05 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-06-21 14:13:33 +0800 |
commit | f45403db19d888266d1cc04756bfef20a26f9f7f (patch) | |
tree | e489e3436ef4da30720292df277ca35dc64cffdd /test | |
parent | 86ea42ce265a5a9df2843b04e8036268593825b9 (diff) | |
download | rneovim-f45403db19d888266d1cc04756bfef20a26f9f7f.tar.gz rneovim-f45403db19d888266d1cc04756bfef20a26f9f7f.tar.bz2 rneovim-f45403db19d888266d1cc04756bfef20a26f9f7f.zip |
vim-patch:9.1.0511: CursorMovedC triggered wrongly with setcmdpos()
Problem: CursorMovedC triggered wrongly with setcmdpos()
(after v9.1.0507)
Solution: Remove the premature triggering. Also don't trigger when
cursor didn't move. (zeertzjq)
closes: vim/vim#15064
https://github.com/vim/vim/commit/bc6f96708e3678dbb27ec4192d87cf94a15d4e9a
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_autocmd.vim | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index 9132e0fdce..3871cb5672 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -2011,20 +2011,28 @@ func Test_Cmdline() 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 : let g:pos += [getcmdpos()] + let g:pos = [] + call feedkeys(":hello\<Left>\<C-R>=''\<CR>\<Left>\<Right>\<Esc>", 'xt') + call assert_equal([5, 4, 5], g:pos) + let g:pos = [] + call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Esc>", 'xt') + call assert_equal([3], g:pos) + let g:pos = [] + call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Left>\<Esc>", 'xt') + call assert_equal([3, 2], 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) + " setcmdpos() is no-op inside an autocommand + au! CursorMovedC : let g:pos += [getcmdpos()] | call setcmdpos(1) + let g:pos = [] + call feedkeys(":hello\<Left>\<Left>\<Esc>", 'xt') + call assert_equal([5, 4], g:pos) au! CursorMovedC + + unlet g:entered + unlet g:left + unlet g:pos endfunc " Test for BufWritePre autocommand that deletes or unloads the buffer. |