diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-07-29 02:36:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-29 02:36:46 +0200 |
commit | caa8c06bae0ff351edb22d566a92a4b1009f191d (patch) | |
tree | 69052a0f25d5b6e9207dacbec2da568866cac92d /src/nvim/edit.c | |
parent | 505f47403ba6a95179ae854c80db07ae77d70947 (diff) | |
download | rneovim-caa8c06bae0ff351edb22d566a92a4b1009f191d.tar.gz rneovim-caa8c06bae0ff351edb22d566a92a4b1009f191d.tar.bz2 rneovim-caa8c06bae0ff351edb22d566a92a4b1009f191d.zip |
vim-patch:8.1.1138: add CompleteChanged #10644
(This was originally a Neovim patch, but this commit merges some changes
from the Vim patch.)
https://github.com/vim/vim/commit/d7f246c68cfb97406bcd4b098a2df2d870b3ef92
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index a3487e012a..06f8cc9413 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2580,10 +2580,35 @@ static bool pum_enough_matches(void) return i >= 2; } -/* - * Show the popup menu for the list of matches. - * Also adjusts "compl_shown_match" to an entry that is actually displayed. - */ +static void trigger_complete_changed_event(int cur) +{ + static bool recursive = false; + + if (recursive) { + return; + } + + dict_T *v_event = get_vim_var_dict(VV_EVENT); + if (cur < 0) { + tv_dict_add_dict(v_event, S_LEN("completed_item"), tv_dict_alloc()); + } else { + dict_T *item = ins_compl_dict_alloc(compl_curr_match); + tv_dict_add_dict(v_event, S_LEN("completed_item"), item); + } + pum_set_event_info(v_event); + tv_dict_set_keys_readonly(v_event); + + recursive = true; + textlock++; + apply_autocmds(EVENT_COMPLETECHANGED, NULL, NULL, false, curbuf); + textlock--; + recursive = false; + + tv_dict_clear(v_event); +} + +/// Show the popup menu for the list of matches. +/// Also adjusts "compl_shown_match" to an entry that is actually displayed. void ins_compl_show_pum(void) { compl_T *compl; @@ -2715,22 +2740,9 @@ void ins_compl_show_pum(void) pum_display(compl_match_array, compl_match_arraysize, cur, array_changed, 0); curwin->w_cursor.col = col; - if (!has_event(EVENT_COMPLETECHANGED)) { - return; + if (has_event(EVENT_COMPLETECHANGED)) { + trigger_complete_changed_event(cur); } - dict_T *dict = get_vim_var_dict(VV_EVENT); - if (cur < 0) { - tv_dict_add_dict(dict, S_LEN("completed_item"), tv_dict_alloc()); - } else { - dict_T *item = ins_compl_dict_alloc(compl_curr_match); - tv_dict_add_dict(dict, S_LEN("completed_item"), item); - } - pum_set_boundings(dict); - tv_dict_set_keys_readonly(dict); - textlock++; - apply_autocmds(EVENT_COMPLETECHANGED, NULL, NULL, false, curbuf); - textlock--; - tv_dict_clear(dict); } #define DICT_FIRST (1) /* use just first element in "dict" */ |