]> granicus.if.org Git - vim/commitdiff
patch 8.0.1445: cannot act on edits in the command line v8.0.1445
authorBram Moolenaar <Bram@vim.org>
Wed, 31 Jan 2018 14:48:32 +0000 (15:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 31 Jan 2018 14:48:32 +0000 (15:48 +0100)
Problem:    Cannot act on edits in the command line.
Solution:   Add the CmdlineChanged autocommand event. (xtal8, closes #2603,
            closes #2524)

runtime/doc/autocmd.txt
src/ex_getln.c
src/fileio.c
src/testdir/test_autocmd.vim
src/version.c
src/vim.h

index 173892cd475f3239b950508dc635c772b1cf9d64..4adf007e7b895ed0c95cbe2c4813cce1dec28c55 100644 (file)
@@ -1,4 +1,4 @@
-*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
@@ -500,6 +500,13 @@ 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 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
index 421c6b7d58f06b7ffa0c7e5752f348543e59d63b..837d29998fcff0bdee000c834a90243cd4a92b29 100644 (file)
@@ -1951,6 +1951,11 @@ cmdline_not_changed:
 #endif
 
 cmdline_changed:
+#ifdef FEAT_AUTOCMD
+       /* Trigger CmdlineChanged autocommands. */
+       trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
+#endif
+
 #ifdef FEAT_SEARCH_EXTRA
        /*
         * 'incsearch' highlighting.
index ba9ec9ec0a02587af118adab829389d10f3138d2..fb5af64466e65beefc39f4df7c803e059be74e5f 100644 (file)
@@ -7786,6 +7786,7 @@ static struct event_name
     {"BufWritePost",   EVENT_BUFWRITEPOST},
     {"BufWritePre",    EVENT_BUFWRITEPRE},
     {"BufWriteCmd",    EVENT_BUFWRITECMD},
+    {"CmdlineChanged", EVENT_CMDLINECHANGED},
     {"CmdlineEnter",   EVENT_CMDLINEENTER},
     {"CmdlineLeave",   EVENT_CMDLINELEAVE},
     {"CmdwinEnter",    EVENT_CMDWINENTER},
index d8fddffebb7467701cbb54f824bc4e272623edb5..b7d43b59adaa75672e064feb8053989b14654380 100644 (file)
@@ -812,6 +812,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
index bab773660fc7042913fdb727afc8e215e5778555..dad27155590b05c773c5c77edd8819fff778df0d 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1445,
 /**/
     1444,
 /**/
index 4765b783b5bf74d5d3e876902b38855549a25b71..1f9671a187639cf4544bf1a37d755d80a4cd40e9 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -1269,6 +1269,7 @@ enum auto_event
     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 */