mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.1.0543: Behavior of CursorMovedC is strange
Problem: Behavior of CursorMovedC is strange. Solution: Also trigger when the cmdline has changed. (zeertzjq) fixes: #15069 closes: #15071 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
e85fdc730e
commit
8145620a95
@@ -1,4 +1,4 @@
|
|||||||
*autocmd.txt* For Vim version 9.1. Last change: 2024 Jul 06
|
*autocmd.txt* For Vim version 9.1. Last change: 2024 Jul 07
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@@ -751,9 +751,8 @@ CursorMoved After the cursor was moved in Normal or Visual
|
|||||||
that is slow.
|
that is slow.
|
||||||
*CursorMovedC*
|
*CursorMovedC*
|
||||||
CursorMovedC After the cursor was moved in the command
|
CursorMovedC After the cursor was moved in the command
|
||||||
line while the text in the command line hasn't
|
line. Be careful not to mess up the command
|
||||||
changed. Be careful not to mess up the
|
line, it may cause Vim to lock up.
|
||||||
command line, it may cause Vim to lock up.
|
|
||||||
<afile> is set to a single character,
|
<afile> is set to a single character,
|
||||||
indicating the type of command-line.
|
indicating the type of command-line.
|
||||||
|cmdwin-char|
|
|cmdwin-char|
|
||||||
|
@@ -2480,13 +2480,13 @@ cmdline_not_changed:
|
|||||||
trigger_cmd_autocmd(cmdline_type, EVENT_CURSORMOVEDC);
|
trigger_cmd_autocmd(cmdline_type, EVENT_CURSORMOVEDC);
|
||||||
prev_cmdpos = ccline.cmdpos;
|
prev_cmdpos = ccline.cmdpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_SEARCH_EXTRA
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
if (!is_state.incsearch_postponed)
|
if (!is_state.incsearch_postponed)
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmdline_changed:
|
cmdline_changed:
|
||||||
prev_cmdpos = ccline.cmdpos;
|
|
||||||
#ifdef FEAT_SEARCH_EXTRA
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
// If the window changed incremental search state is not valid.
|
// If the window changed incremental search state is not valid.
|
||||||
if (is_state.winid != curwin->w_id)
|
if (is_state.winid != curwin->w_id)
|
||||||
@@ -2496,6 +2496,13 @@ cmdline_changed:
|
|||||||
if (trigger_cmdlinechanged)
|
if (trigger_cmdlinechanged)
|
||||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
|
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
|
||||||
|
|
||||||
|
// Trigger CursorMovedC autocommands.
|
||||||
|
if (ccline.cmdpos != prev_cmdpos)
|
||||||
|
{
|
||||||
|
trigger_cmd_autocmd(cmdline_type, EVENT_CURSORMOVEDC);
|
||||||
|
prev_cmdpos = ccline.cmdpos;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FEAT_SEARCH_EXTRA
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
if (xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL))
|
if (xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL))
|
||||||
may_do_incsearch_highlighting(firstc, count, &is_state);
|
may_do_incsearch_highlighting(firstc, count, &is_state);
|
||||||
|
@@ -2099,21 +2099,30 @@ func Test_Cmdline()
|
|||||||
|
|
||||||
au! CursorMovedC : let g:pos += [getcmdpos()]
|
au! CursorMovedC : let g:pos += [getcmdpos()]
|
||||||
let g:pos = []
|
let g:pos = []
|
||||||
|
call feedkeys(":foo bar baz\<C-W>\<C-W>\<C-W>\<Esc>", 'xt')
|
||||||
|
call assert_equal([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 9, 5, 1], g:pos)
|
||||||
|
let g:pos = []
|
||||||
|
call feedkeys(":hello\<C-B>\<Esc>", 'xt')
|
||||||
|
call assert_equal([2, 3, 4, 5, 6, 1], g:pos)
|
||||||
|
let g:pos = []
|
||||||
|
call feedkeys(":hello\<C-U>\<Esc>", 'xt')
|
||||||
|
call assert_equal([2, 3, 4, 5, 6, 1], g:pos)
|
||||||
|
let g:pos = []
|
||||||
call feedkeys(":hello\<Left>\<C-R>=''\<CR>\<Left>\<Right>\<Esc>", 'xt')
|
call feedkeys(":hello\<Left>\<C-R>=''\<CR>\<Left>\<Right>\<Esc>", 'xt')
|
||||||
call assert_equal([5, 4, 5], g:pos)
|
call assert_equal([2, 3, 4, 5, 6, 5, 4, 5], g:pos)
|
||||||
let g:pos = []
|
let g:pos = []
|
||||||
call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Esc>", 'xt')
|
call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Esc>", 'xt')
|
||||||
call assert_equal([3], g:pos)
|
call assert_equal([2, 3, 4, 5, 6, 7, 8, 9, 3], g:pos)
|
||||||
let g:pos = []
|
let g:pos = []
|
||||||
call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Left>\<Esc>", 'xt')
|
call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Left>\<Esc>", 'xt')
|
||||||
call assert_equal([3, 2], g:pos)
|
call assert_equal([2, 3, 4, 5, 6, 7, 8, 9, 3, 2], g:pos)
|
||||||
au! CursorMovedC
|
au! CursorMovedC
|
||||||
|
|
||||||
" setcmdpos() is no-op inside an autocommand
|
" setcmdpos() is no-op inside an autocommand
|
||||||
au! CursorMovedC : let g:pos += [getcmdpos()] | call setcmdpos(1)
|
au! CursorMovedC : let g:pos += [getcmdpos()] | call setcmdpos(1)
|
||||||
let g:pos = []
|
let g:pos = []
|
||||||
call feedkeys(":hello\<Left>\<Left>\<Esc>", 'xt')
|
call feedkeys(":hello\<Left>\<Left>\<Esc>", 'xt')
|
||||||
call assert_equal([5, 4], g:pos)
|
call assert_equal([2, 3, 4, 5, 6, 5, 4], g:pos)
|
||||||
au! CursorMovedC
|
au! CursorMovedC
|
||||||
|
|
||||||
unlet g:entered
|
unlet g:entered
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
543,
|
||||||
/**/
|
/**/
|
||||||
542,
|
542,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user