Problem: Cannot act on edits in the command line.
Solution: Add the CmdlineChanged autocommand event. (xtal8, closes #2603,
closes #2524)
-*autocmd.txt* For Vim version 8.0. Last change: 2017 Dec 17
+*autocmd.txt* For Vim version 8.0. Last change: 2018 Jan 31
VIM REFERENCE MANUAL by Bram Moolenaar
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 inside
+ command line. Be careful not to mess up the
+ command line, it may cause Vim to lock up.
+ <afile> is set to a single character,
+ indicating the type of command-line.
+ |cmdwin-char|
*CmdlineEnter*
CmdlineEnter After moving the cursor to the command line,
where the user can type a command or search
#endif
cmdline_changed:
+#ifdef FEAT_AUTOCMD
+ /* Trigger CmdlineChanged autocommands. */
+ trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
+#endif
+
#ifdef FEAT_SEARCH_EXTRA
/*
* 'incsearch' highlighting.
{"BufWritePost", EVENT_BUFWRITEPOST},
{"BufWritePre", EVENT_BUFWRITEPRE},
{"BufWriteCmd", EVENT_BUFWRITECMD},
+ {"CmdlineChanged", EVENT_CMDLINECHANGED},
{"CmdlineEnter", EVENT_CMDLINEENTER},
{"CmdlineLeave", EVENT_CMDLINELEAVE},
{"CmdwinEnter", EVENT_CMDWINENTER},
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1445,
/**/
1444,
/**/
EVENT_BUFWRITEPOST, /* after writing a buffer */
EVENT_BUFWRITEPRE, /* before writing a buffer */
EVENT_BUFWRITECMD, /* write buffer using command */
+ EVENT_CMDLINECHANGED, /* command line was modified*/
EVENT_CMDLINEENTER, /* after entering the command line */
EVENT_CMDLINELEAVE, /* before leaving the command line */
EVENT_CMDWINENTER, /* after entering the cmdline window */