mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 21:18:34 +00:00
vim-patch:9.1.0905: Missing information in CompleteDone event (#31455)
Problem: Missing information in CompleteDone event
Solution: add complete_word and complete_type to v:event dict
(glepnir)
closes: vim/vim#16153
1c5a120a70
This commit is contained in:
@@ -561,11 +561,19 @@ static bool is_first_match(const compl_T *const match)
|
||||
return match == compl_first_match;
|
||||
}
|
||||
|
||||
static void do_autocmd_completedone(int c)
|
||||
static void do_autocmd_completedone(int c, int mode, char *word)
|
||||
{
|
||||
save_v_event_T save_v_event;
|
||||
dict_T *v_event = get_v_event(&save_v_event);
|
||||
|
||||
mode = mode & ~CTRL_X_WANT_IDENT;
|
||||
char *mode_str = NULL;
|
||||
if (ctrl_x_mode_names[mode]) {
|
||||
mode_str = ctrl_x_mode_names[mode];
|
||||
}
|
||||
tv_dict_add_str(v_event, S_LEN("complete_word"), word != NULL ? word : "");
|
||||
tv_dict_add_str(v_event, S_LEN("complete_type"), mode_str != NULL ? mode_str : "");
|
||||
|
||||
tv_dict_add_str(v_event, S_LEN("reason"), (c == Ctrl_Y ? "accept" : "cancel"));
|
||||
tv_dict_set_keys_readonly(v_event);
|
||||
|
||||
@@ -2115,12 +2123,14 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
|
||||
}
|
||||
}
|
||||
|
||||
char *word = NULL;
|
||||
// If the popup menu is displayed pressing CTRL-Y means accepting
|
||||
// the selection without inserting anything. When
|
||||
// compl_enter_selects is set the Enter key does the same.
|
||||
if ((c == Ctrl_Y || (compl_enter_selects
|
||||
&& (c == CAR || c == K_KENTER || c == NL)))
|
||||
&& pum_visible()) {
|
||||
word = xstrdup(compl_shown_match->cp_str);
|
||||
retval = true;
|
||||
}
|
||||
|
||||
@@ -2178,7 +2188,8 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
|
||||
}
|
||||
// Trigger the CompleteDone event to give scripts a chance to act
|
||||
// upon the end of completion.
|
||||
do_autocmd_completedone(c);
|
||||
do_autocmd_completedone(c, prev_mode, word);
|
||||
xfree(word);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -2267,7 +2278,7 @@ bool ins_compl_prep(int c)
|
||||
} else if (ctrl_x_mode == CTRL_X_LOCAL_MSG) {
|
||||
// Trigger the CompleteDone event to give scripts a chance to act
|
||||
// upon the (possibly failed) completion.
|
||||
do_autocmd_completedone(c);
|
||||
do_autocmd_completedone(c, ctrl_x_mode, NULL);
|
||||
}
|
||||
|
||||
may_trigger_modechanged();
|
||||
|
@@ -208,6 +208,8 @@ M.vars = {
|
||||
changing window (or tab) on |DirChanged|.
|
||||
status Job status or exit code, -1 means "unknown". |TermClose|
|
||||
reason Reason for completion being done. |CompleteDone|
|
||||
complete_word The word that was selected, empty if abandoned complete.
|
||||
complete_type See |complete_info_mode|
|
||||
]=],
|
||||
},
|
||||
exception = {
|
||||
|
Reference in New Issue
Block a user