Skip to content

Commit 4418041

Browse files
glepnirchrisbra
authored andcommitted
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 <[email protected]> Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 3af0a8d commit 4418041

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

src/insexpand.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,7 @@ ins_compl_new_leader(void)
21092109
compl_restarting = FALSE;
21102110
}
21112111

2112-
compl_enter_selects = !compl_used_match;
2112+
compl_enter_selects = !compl_used_match && compl_selected_item != -1;
21132113

21142114
// Show the popup menu with a different set of matches.
21152115
ins_compl_show_pum();
@@ -2580,10 +2580,6 @@ ins_compl_prep(int c)
25802580
{
25812581
int retval = FALSE;
25822582
int prev_mode = ctrl_x_mode;
2583-
int handle_enter = FALSE;
2584-
2585-
if ((c == CAR || c == NL || c == K_KENTER) && compl_selected_item == -1)
2586-
handle_enter = TRUE;
25872583

25882584
// Forget any previous 'special' messages if this is actually
25892585
// a ^X mode key - bar ^R, in which case we wait to see what it gives us.
@@ -2681,14 +2677,7 @@ ins_compl_prep(int c)
26812677
if ((ctrl_x_mode_normal() && c != Ctrl_N && c != Ctrl_P
26822678
&& c != Ctrl_R && !ins_compl_pum_key(c))
26832679
|| ctrl_x_mode == CTRL_X_FINISHED)
2684-
{
26852680
retval = ins_compl_stop(c, prev_mode, retval);
2686-
// When it is the Enter key and no selected item, return false, and
2687-
// continue processing the Enter key to insert a new line in the
2688-
// edit function.
2689-
if (retval && handle_enter)
2690-
retval = FALSE;
2691-
}
26922681
}
26932682
else if (ctrl_x_mode == CTRL_X_LOCAL_MSG)
26942683
// Trigger the CompleteDone event to give scripts a chance to act

src/testdir/test_edit.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ func Test_edit_CTRL_I()
594594
call assert_equal([include, 'two', ''], getline(1, '$'))
595595
call feedkeys("2ggC\<c-x>\<tab>\<down>\<down>\<cr>\<esc>", 'tnix')
596596
call assert_equal([include, 'three', ''], getline(1, '$'))
597-
call feedkeys("2ggC\<c-x>\<tab>\<down>\<down>\<down>\<C-y>\<esc>", 'tnix')
597+
call feedkeys("2ggC\<c-x>\<tab>\<down>\<down>\<down>\<cr>\<esc>", 'tnix')
598598
call assert_equal([include, '', ''], getline(1, '$'))
599599
bw!
600600
endfunc
@@ -622,7 +622,7 @@ func Test_edit_CTRL_K()
622622
%d
623623
call setline(1, 'A')
624624
call cursor(1, 1)
625-
call feedkeys("A\<c-x>\<c-k>\<down>\<down>\<down>\<C-Y>\<esc>", 'tnix')
625+
call feedkeys("A\<c-x>\<c-k>\<down>\<down>\<down>\<cr>\<esc>", 'tnix')
626626
call assert_equal(['A'], getline(1, '$'))
627627
%d
628628
call setline(1, 'A')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1126,
707709
/**/
708710
1125,
709711
/**/

0 commit comments

Comments
 (0)