mirror of
https://github.com/neovim/neovim.git
synced 2025-12-09 16:12:48 +00:00
vim-patch:8.0.1445: cannot act on edits in the command line
Problem: Cannot act on edits in the command line.
Solution: Add the CmdlineChanged autocommand event. (xtal8, closes vim/vim#2603,
closes vim/vim#2524)
153b704e20
This commit is contained in:
@@ -521,10 +521,11 @@ CmdUndefined When a user command is used but it isn't
|
||||
command is defined. An alternative is to
|
||||
always define the user command and have it
|
||||
invoke an autoloaded function. See |autoload|.
|
||||
*CmdlineChanged*
|
||||
CmdlineChanged After a change was made to the text in the
|
||||
command line. Be careful not to mess up
|
||||
the command line, it may cause Vim to lock up.
|
||||
*CmdlineChanged*
|
||||
CmdlineChanged After a change was made to the text inside
|
||||
command line. Be careful not to mess up the
|
||||
command line, it may cause Vim to lock up.
|
||||
<afile> is set to the |cmdline-char|.
|
||||
*CmdlineEnter*
|
||||
CmdlineEnter After entering the command-line (including
|
||||
non-interactive use of ":" in a mapping: use
|
||||
|
||||
@@ -21,6 +21,7 @@ return {
|
||||
'BufWritePre', -- before writing a buffer
|
||||
'ChanInfo', -- info was received about channel
|
||||
'ChanOpen', -- channel was opened
|
||||
'CmdLineChanged', -- command line was modified
|
||||
'CmdLineEnter', -- after entering cmdline mode
|
||||
'CmdLineLeave', -- before leaving cmdline mode
|
||||
'CmdUndefined', -- command undefined
|
||||
|
||||
@@ -1804,6 +1804,13 @@ static int empty_pattern(char_u *p)
|
||||
|
||||
static int command_line_changed(CommandLineState *s)
|
||||
{
|
||||
// Trigger CmdlineChanged autocommands.
|
||||
char firstcbuf[2];
|
||||
firstcbuf[0] = s->firstc > 0 ? s->firstc : '-';
|
||||
firstcbuf[1] = 0;
|
||||
apply_autocmds(EVENT_CMDLINECHANGED, (char_u *)firstcbuf, (char_u *)firstcbuf,
|
||||
false, curbuf);
|
||||
|
||||
// 'incsearch' highlighting.
|
||||
if (p_is && !cmd_silent && (s->firstc == '/' || s->firstc == '?')) {
|
||||
pos_T end_pos;
|
||||
|
||||
@@ -818,6 +818,18 @@ func Test_QuitPre()
|
||||
endfunc
|
||||
|
||||
func Test_Cmdline()
|
||||
au! CmdlineChanged : let g:text = getcmdline()
|
||||
let g:text = 0
|
||||
call feedkeys(":echom 'hello'\<CR>", 'xt')
|
||||
call assert_equal("echom 'hello'", g:text)
|
||||
au! CmdlineChanged
|
||||
|
||||
au! CmdlineChanged : let g:entered = expand('<afile>')
|
||||
let g:entered = 0
|
||||
call feedkeys(":echom 'hello'\<CR>", 'xt')
|
||||
call assert_equal(':', g:entered)
|
||||
au! CmdlineChanged
|
||||
|
||||
au! CmdlineEnter : let g:entered = expand('<afile>')
|
||||
au! CmdlineLeave : let g:left = expand('<afile>')
|
||||
let g:entered = 0
|
||||
|
||||
Reference in New Issue
Block a user