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: #1653
closes: #16653
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/insexpand.c b/src/insexpand.c
index 7d04690..f696097 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -1889,6 +1889,7 @@
compl_cont_status = 0;
compl_started = FALSE;
compl_matches = 0;
+ compl_selected_item = -1;
compl_ins_end_col = 0;
VIM_CLEAR_STRING(compl_pattern);
VIM_CLEAR_STRING(compl_leader);
@@ -2579,6 +2580,10 @@
{
int retval = FALSE;
int prev_mode = ctrl_x_mode;
+ int handle_enter = FALSE;
+
+ if ((c == CAR || c == NL || c == K_KENTER) && compl_selected_item == -1)
+ handle_enter = TRUE;
// 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.
@@ -2676,7 +2681,14 @@
if ((ctrl_x_mode_normal() && c != Ctrl_N && c != Ctrl_P
&& c != Ctrl_R && !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