To: vim_dev@googlegroups.com Subject: Patch 8.0.1445 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1445 Problem: Cannot act on edits in the command line. Solution: Add the CmdlineChanged autocommand event. (xtal8, closes #2603, closes #2524) Files: runtime/doc/autocmd.txt, src/ex_getln.c, src/fileio.c, src/testdir/test_autocmd.vim, src/vim.h *** ../vim-8.0.1444/runtime/doc/autocmd.txt 2017-12-16 18:26:56.618992550 +0100 --- runtime/doc/autocmd.txt 2018-01-31 15:38:35.224999357 +0100 *************** *** 484,489 **** --- 500,512 ---- 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. + 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 *************** *** 493,498 **** --- 516,525 ---- |cmdwin-char| *CmdlineLeave* CmdlineLeave Before leaving the command line. + Also when abandoning the command line, after + typing CTRL-C or . + When the commands result in an error the + command line is still executed. is set to a single character, indicating the type of command-line. |cmdwin-char| *** ../vim-8.0.1444/src/ex_getln.c 2018-01-02 15:37:42.370832263 +0100 --- src/ex_getln.c 2018-01-31 15:36:07.985993217 +0100 *************** *** 1951,1956 **** --- 1951,1961 ---- #endif cmdline_changed: + #ifdef FEAT_AUTOCMD + /* Trigger CmdlineChanged autocommands. */ + trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED); + #endif + #ifdef FEAT_SEARCH_EXTRA /* * 'incsearch' highlighting. *** ../vim-8.0.1444/src/fileio.c 2017-12-16 18:26:56.622992523 +0100 --- src/fileio.c 2018-01-31 15:36:07.989993189 +0100 *************** *** 7786,7791 **** --- 7786,7792 ---- {"BufWritePost", EVENT_BUFWRITEPOST}, {"BufWritePre", EVENT_BUFWRITEPRE}, {"BufWriteCmd", EVENT_BUFWRITECMD}, + {"CmdlineChanged", EVENT_CMDLINECHANGED}, {"CmdlineEnter", EVENT_CMDLINEENTER}, {"CmdlineLeave", EVENT_CMDLINELEAVE}, {"CmdwinEnter", EVENT_CMDWINENTER}, *** ../vim-8.0.1444/src/testdir/test_autocmd.vim 2017-12-21 20:54:45.129204547 +0100 --- src/testdir/test_autocmd.vim 2018-01-31 15:36:07.989993189 +0100 *************** *** 812,817 **** --- 812,829 ---- endfunc func Test_Cmdline() + au! CmdlineChanged : let g:text = getcmdline() + let g:text = 0 + call feedkeys(":echom 'hello'\", 'xt') + call assert_equal("echom 'hello'", g:text) + au! CmdlineChanged + + au! CmdlineChanged : let g:entered = expand('') + let g:entered = 0 + call feedkeys(":echom 'hello'\", 'xt') + call assert_equal(':', g:entered) + au! CmdlineChanged + au! CmdlineEnter : let g:entered = expand('') au! CmdlineLeave : let g:left = expand('') let g:entered = 0 *** ../vim-8.0.1444/src/vim.h 2017-12-16 18:26:56.626992497 +0100 --- src/vim.h 2018-01-31 15:36:07.989993189 +0100 *************** *** 1269,1274 **** --- 1269,1275 ---- 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 */ *** ../vim-8.0.1444/src/version.c 2018-01-31 14:41:32.479620562 +0100 --- src/version.c 2018-01-31 15:37:22.933487480 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1445, /**/ -- press CTRL-ALT-DEL for more information /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///