To: vim_dev@googlegroups.com Subject: Patch 8.2.0158 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0158 (after 8.2.0123) Problem: Triggering CompleteDone earlier is not backwards compatible. (Daniel Hahler) Solution: Add CompleteDonePre instead. Files: src/insexpand.c, runtime/doc/autocmd.txt, src/autocmd.c, src/vim.h, src/testdir/test_ins_complete.vim *** ../vim-8.2.0157/src/insexpand.c 2020-01-26 18:35:28.722033545 +0100 --- src/insexpand.c 2020-01-26 22:22:48.593674626 +0100 *************** *** 2061,2072 **** auto_format(FALSE, TRUE); ! // Trigger the CompleteDone event to give scripts a chance to ! // act upon the completion. Do this before clearing the info, ! // and restore ctrl_x_mode, so that complete_info() can be ! // used. ctrl_x_mode = prev_mode; ! ins_apply_autocmds(EVENT_COMPLETEDONE); ins_compl_free(); compl_started = FALSE; --- 2061,2071 ---- auto_format(FALSE, TRUE); ! // Trigger the CompleteDonePre event to give scripts a chance to ! // act upon the completion before clearing the info, and restore ! // ctrl_x_mode, so that complete_info() can be used. ctrl_x_mode = prev_mode; ! ins_apply_autocmds(EVENT_COMPLETEDONEPRE); ins_compl_free(); compl_started = FALSE; *************** *** 2092,2097 **** --- 2091,2099 ---- if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0))) do_c_expr_indent(); #endif + // Trigger the CompleteDone event to give scripts a chance to act + // upon the end of completion. + ins_apply_autocmds(EVENT_COMPLETEDONE); } } else if (ctrl_x_mode == CTRL_X_LOCAL_MSG) *** ../vim-8.2.0157/runtime/doc/autocmd.txt 2020-01-17 18:58:37.159223076 +0100 --- runtime/doc/autocmd.txt 2020-01-26 22:25:30.180925392 +0100 *************** *** 374,380 **** |MenuPopup| just before showing the popup menu |CompleteChanged| after Insert mode completion menu changed ! |CompleteDone| after Insert mode completion is done |User| to be used in combination with ":doautocmd" --- 374,383 ---- |MenuPopup| just before showing the popup menu |CompleteChanged| after Insert mode completion menu changed ! |CompleteDonePre| after Insert mode completion is done, before clearing ! info ! |CompleteDone| after Insert mode completion is done, after clearing ! info |User| to be used in combination with ":doautocmd" *************** *** 589,596 **** CompleteChanged *CompleteChanged* After each time the Insert mode completion menu changed. Not fired on popup menu hide, ! use |CompleteDone| for that. Never triggered ! recursively. Sets these |v:event| keys: completed_item See |complete-items|. --- 592,599 ---- CompleteChanged *CompleteChanged* After each time the Insert mode completion menu changed. Not fired on popup menu hide, ! use |CompleteDonePre| or |CompleteDone| for ! that. Never triggered recursively. Sets these |v:event| keys: completed_item See |complete-items|. *************** *** 606,617 **** The size and position of the popup are also available by calling |pum_getpos()|. *CompleteDone* CompleteDone After Insert mode completion is done. Either when something was completed or abandoning completion. |ins-completion| ! |complete_info()| can be used, the info is ! cleared after triggering CompleteDone. The |v:completed_item| variable contains information about the completed item. --- 609,630 ---- The size and position of the popup are also available by calling |pum_getpos()|. + *CompleteDonePre* + CompleteDonePre After Insert mode completion is done. Either + when something was completed or abandoning + completion. |ins-completion| + |complete_info()| can be used, the info is + cleared after triggering CompleteDonePre. + The |v:completed_item| variable contains + information about the completed item. + *CompleteDone* CompleteDone After Insert mode completion is done. Either when something was completed or abandoning completion. |ins-completion| ! |complete_info()| cannot be used, the info is ! cleared before triggering CompleteDone. Use ! CompleteDonePre if you need it. The |v:completed_item| variable contains information about the completed item. *** ../vim-8.2.0157/src/autocmd.c 2020-01-07 20:59:30.524926537 +0100 --- src/autocmd.c 2020-01-26 22:26:57.928520038 +0100 *************** *** 114,119 **** --- 114,120 ---- {"ColorSchemePre", EVENT_COLORSCHEMEPRE}, {"CompleteChanged", EVENT_COMPLETECHANGED}, {"CompleteDone", EVENT_COMPLETEDONE}, + {"CompleteDonePre", EVENT_COMPLETEDONEPRE}, {"CursorHold", EVENT_CURSORHOLD}, {"CursorHoldI", EVENT_CURSORHOLDI}, {"CursorMoved", EVENT_CURSORMOVED}, *** ../vim-8.2.0157/src/vim.h 2020-01-26 15:52:33.027833222 +0100 --- src/vim.h 2020-01-26 22:27:24.192398873 +0100 *************** *** 1303,1308 **** --- 1303,1309 ---- EVENT_COLORSCHEMEPRE, // before loading a colorscheme EVENT_COMPLETECHANGED, // after completion popup menu changed EVENT_COMPLETEDONE, // after finishing insert complete + EVENT_COMPLETEDONEPRE, // idem, before clearing info EVENT_CURSORHOLD, // cursor in same position for a while EVENT_CURSORHOLDI, // idem, in Insert mode EVENT_CURSORMOVED, // cursor was moved *** ../vim-8.2.0157/src/testdir/test_ins_complete.vim 2020-01-17 18:58:37.159223076 +0100 --- src/testdir/test_ins_complete.vim 2020-01-26 22:41:41.320569600 +0100 *************** *** 175,181 **** let s:called_completedone = 1 endfunc ! func s:CompleteDone_CheckCompletedItemDict() call assert_equal( 'aword', v:completed_item[ 'word' ] ) call assert_equal( 'wrd', v:completed_item[ 'abbr' ] ) call assert_equal( 'extra text', v:completed_item[ 'menu' ] ) --- 175,181 ---- let s:called_completedone = 1 endfunc ! func s:CompleteDone_CheckCompletedItemDict(pre) call assert_equal( 'aword', v:completed_item[ 'word' ] ) call assert_equal( 'wrd', v:completed_item[ 'abbr' ] ) call assert_equal( 'extra text', v:completed_item[ 'menu' ] ) *************** *** 183,189 **** call assert_equal( 'W', v:completed_item[ 'kind' ] ) call assert_equal( 'test', v:completed_item[ 'user_data' ] ) ! call assert_equal('function', complete_info().mode) let s:called_completedone = 1 endfunc --- 183,191 ---- call assert_equal( 'W', v:completed_item[ 'kind' ] ) call assert_equal( 'test', v:completed_item[ 'user_data' ] ) ! if a:pre ! call assert_equal('function', complete_info().mode) ! endif let s:called_completedone = 1 endfunc *************** *** 205,211 **** endfunc func Test_CompleteDoneDict() ! au CompleteDone * :call CompleteDone_CheckCompletedItemDict() set completefunc=CompleteDone_CompleteFuncDict execute "normal a\\\" --- 207,214 ---- endfunc func Test_CompleteDoneDict() ! au CompleteDonePre * :call CompleteDone_CheckCompletedItemDict(1) ! au CompleteDone * :call CompleteDone_CheckCompletedItemDict(0) set completefunc=CompleteDone_CompleteFuncDict execute "normal a\\\" *** ../vim-8.2.0157/src/version.c 2020-01-26 22:05:01.030873636 +0100 --- src/version.c 2020-01-26 22:42:47.608275943 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 158, /**/ -- Bad fashion can discourage normal people from interacting with the engineer and talking about the cute things their children do. (Scott Adams - The Dilbert principle) /// 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 ///