patch 9.1.1126: patch 9.1.1121 used a wrong way to handle enter
Problem: patch 9.1.1121 used a wrong way to handle enter
Solution: compl_enter_selects also needs to consider the selected item
in ins_compl_new_leader() (glepnir)
closes: #16673
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/insexpand.c b/src/insexpand.c
index f280156..624165a 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -2109,7 +2109,7 @@
compl_restarting = FALSE;
}
- compl_enter_selects = !compl_used_match;
+ compl_enter_selects = !compl_used_match && compl_selected_item != -1;
// Show the popup menu with a different set of matches.
ins_compl_show_pum();
@@ -2580,10 +2580,6 @@
{
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.
@@ -2681,14 +2677,7 @@
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