diff options
author | glepnir <glephunter@gmail.com> | 2025-02-19 13:40:46 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2025-02-21 07:45:30 +0800 |
commit | 07785ea9c5595f379f2cac2ce8ffa95244e3d8e3 (patch) | |
tree | c3b1f2224d694097642c40b324934f512a448019 /src | |
parent | 99a6cbe5409dc296d6a5597733d92f63d8bca27e (diff) | |
download | rneovim-07785ea9c5595f379f2cac2ce8ffa95244e3d8e3.tar.gz rneovim-07785ea9c5595f379f2cac2ce8ffa95244e3d8e3.tar.bz2 rneovim-07785ea9c5595f379f2cac2ce8ffa95244e3d8e3.zip |
vim-patch:9.1.1121: Enter does not insert newline with "noselect"
Problem: Enter does not insert newline with "noselect" when the pum is
visible (lifepillar)
Solution: When Enter is pressed and no complete-item is selected,
ins_compl_prep returns false, and the edit function continues
processing Enter to insert a new line. (glepnir)
fixes: vim/vim#1653
closes: vim/vim#16653
https://github.com/vim/vim/commit/07f0dbe3aa326fdf4d0f1b1cf7d79df89e91fc6e
Co-authored-by: glepnir <glephunter@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/insexpand.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index e88f5dbe70..c33c4a1ad9 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1744,6 +1744,7 @@ void ins_compl_clear(void) compl_cont_status = 0; compl_started = false; compl_matches = 0; + compl_selected_item = -1; compl_ins_end_col = 0; API_CLEAR_STRING(compl_pattern); API_CLEAR_STRING(compl_leader); @@ -2300,6 +2301,7 @@ bool ins_compl_prep(int c) { bool retval = false; const int prev_mode = ctrl_x_mode; + bool handle_enter = ((c == CAR || c == NL || c == K_KENTER) && compl_selected_item == -1); // Forget any previous 'special' messages if this is actually // a ^X mode key - bar ^R, in which case we wait to see what it gives us. @@ -2366,6 +2368,12 @@ bool ins_compl_prep(int c) && !ins_compl_pum_key(c)) || ctrl_x_mode == CTRL_X_FINISHED) { retval = ins_compl_stop(c, prev_mode, retval); + // When it is the Enter key and no selected item, return false, and + // continue processing the Enter key to insert a new line in the + // edit function. + if (retval && handle_enter) { + retval = false; + } } } else if (ctrl_x_mode == CTRL_X_LOCAL_MSG) { // Trigger the CompleteDone event to give scripts a chance to act |