Merge #11772 from janlazo/vim-8.2.0152

vim-patch:8.2.{152,158}
This commit is contained in:
Justin M. Keyes
2020-01-26 19:54:26 -08:00
committed by GitHub
4 changed files with 34 additions and 19 deletions

View File

@@ -358,7 +358,10 @@ Name triggered by ~
|MenuPopup| just before showing the popup menu |MenuPopup| just before showing the popup menu
|CompleteChanged| after popup menu changed, not fired on popup menu hide |CompleteChanged| after popup menu changed, not fired on popup menu hide
|CompleteDone| after Insert mode completion is done |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" |User| to be used in combination with ":doautocmd"
|Signal| after Nvim receives a signal |Signal| after Nvim receives a signal
@@ -577,7 +580,8 @@ ColorSchemePre Before loading a color scheme. |:colorscheme|
CompleteChanged *CompleteChanged* CompleteChanged *CompleteChanged*
After each time the Insert mode completion After each time the Insert mode completion
menu changed. Not fired on popup menu hide, menu changed. Not fired on popup menu hide,
use |CompleteDone| for that. use |CompleteDonePre| or |CompleteDone| for
that.
Sets these |v:event| keys: Sets these |v:event| keys:
completed_item See |complete-items|. completed_item See |complete-items|.
@@ -594,12 +598,22 @@ CompleteChanged *CompleteChanged*
The size and position of the popup are also The size and position of the popup are also
available by calling |pum_getpos()|. 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*
CompleteDone After Insert mode completion is done. Either CompleteDone After Insert mode completion is done. Either
when something was completed or abandoning when something was completed or abandoning
completion. |ins-completion| completion. |ins-completion|
|complete_info()| can be used, the info is |complete_info()| cannot be used, the info is
cleared after triggering CompleteDone. cleared before triggering CompleteDone. Use
CompleteDonePre if you need it.
|v:completed_item| gives the completed item. |v:completed_item| gives the completed item.
*CursorHold* *CursorHold*

View File

@@ -31,6 +31,7 @@ return {
'ColorSchemePre', -- before loading a colorscheme 'ColorSchemePre', -- before loading a colorscheme
'CompleteChanged', -- after popup menu changed 'CompleteChanged', -- after popup menu changed
'CompleteDone', -- after finishing insert complete 'CompleteDone', -- after finishing insert complete
'CompleteDonePre', -- idem, before clearing info
'CursorHold', -- cursor in same position for a while 'CursorHold', -- cursor in same position for a while
'CursorHoldI', -- idem, in Insert mode 'CursorHoldI', -- idem, in Insert mode
'CursorMoved', -- cursor was moved 'CursorMoved', -- cursor was moved

View File

@@ -3594,17 +3594,11 @@ static bool ins_compl_prep(int c)
auto_format(FALSE, TRUE); auto_format(FALSE, TRUE);
{ // Trigger the CompleteDonePre event to give scripts a chance to
const int new_mode = ctrl_x_mode; // act upon the completion before clearing the info, and restore
// ctrl_x_mode, so that complete_info() can be used.
// 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; ctrl_x_mode = prev_mode;
ins_apply_autocmds(EVENT_COMPLETEDONE); ins_apply_autocmds(EVENT_COMPLETEDONEPRE);
ctrl_x_mode = new_mode;
}
ins_compl_free(); ins_compl_free();
compl_started = false; compl_started = false;
@@ -3630,6 +3624,9 @@ static bool ins_compl_prep(int c)
*/ */
if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0))) if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0)))
do_c_expr_indent(); do_c_expr_indent();
// 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) } else if (ctrl_x_mode == CTRL_X_LOCAL_MSG)
/* Trigger the CompleteDone event to give scripts a chance to act /* Trigger the CompleteDone event to give scripts a chance to act

View File

@@ -130,7 +130,7 @@ func s:CompleteDone_CheckCompletedItemNone()
let s:called_completedone = 1 let s:called_completedone = 1
endfunc endfunc
function! s:CompleteDone_CheckCompletedItemDict() func s:CompleteDone_CheckCompletedItemDict(pre)
call assert_equal( 'aword', v:completed_item[ 'word' ] ) call assert_equal( 'aword', v:completed_item[ 'word' ] )
call assert_equal( 'wrd', v:completed_item[ 'abbr' ] ) call assert_equal( 'wrd', v:completed_item[ 'abbr' ] )
call assert_equal( 'extra text', v:completed_item[ 'menu' ] ) call assert_equal( 'extra text', v:completed_item[ 'menu' ] )
@@ -138,10 +138,12 @@ function! s:CompleteDone_CheckCompletedItemDict()
call assert_equal( 'W', v:completed_item[ 'kind' ] ) call assert_equal( 'W', v:completed_item[ 'kind' ] )
call assert_equal( 'test', v:completed_item[ 'user_data' ] ) call assert_equal( 'test', v:completed_item[ 'user_data' ] )
if a:pre
call assert_equal('function', complete_info().mode) call assert_equal('function', complete_info().mode)
endif
let s:called_completedone = 1 let s:called_completedone = 1
endfunction endfunc
func Test_CompleteDoneNone() func Test_CompleteDoneNone()
throw 'skipped: Nvim does not support v:none' throw 'skipped: Nvim does not support v:none'
@@ -161,7 +163,8 @@ func Test_CompleteDoneNone()
endfunc endfunc
func Test_CompleteDoneDict() func Test_CompleteDoneDict()
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDict() au CompleteDonePre * :call <SID>CompleteDone_CheckCompletedItemDict(1)
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDict(0)
set completefunc=<SID>CompleteDone_CompleteFuncDict set completefunc=<SID>CompleteDone_CompleteFuncDict
execute "normal a\<C-X>\<C-U>\<C-Y>" execute "normal a\<C-X>\<C-U>\<C-Y>"