Skip to content

Commit f3d0d08

Browse files
girishjichrisbra
authored andcommitted
patch 9.1.1827: completion: v9.1.1797 broke Ctrl-Y behaviour
Problem: completion: v9.1.1797 broke Ctrl-Y behaviour (ddad431, after v9.1.1797) Solution: Restore correct behaviour (Girish Palya). closes: #18494 Signed-off-by: Girish Palya <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent a76ea52 commit f3d0d08

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

src/edit.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,12 +693,15 @@ edit(
693693
&& stop_arrow() == OK)
694694
{
695695
ins_compl_delete();
696-
ins_compl_insert(FALSE, !ins_compl_has_preinsert());
697-
if (ins_compl_preinsert_longest())
696+
if (ins_compl_preinsert_longest()
697+
&& !ins_compl_is_match_selected())
698698
{
699+
ins_compl_insert(FALSE, TRUE);
699700
ins_compl_init_get_longest();
700701
continue;
701702
}
703+
else
704+
ins_compl_insert(FALSE, FALSE);
702705
}
703706
// Delete preinserted text when typing special chars
704707
else if (IS_WHITE_NL_OR_NUL(c) && ins_compl_preinsert_effect())

src/insexpand.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,15 @@ is_nearest_active(void)
853853
&& !(flags & COT_FUZZY);
854854
}
855855

856+
/*
857+
* TRUE if a match is selected (even if it is not inserted).
858+
*/
859+
int
860+
ins_compl_is_match_selected(void)
861+
{
862+
return compl_shown_match != NULL && !is_first_match(compl_shown_match);
863+
}
864+
856865
/*
857866
* Returns TRUE if autocomplete is active and the pre-insert effect targets the
858867
* longest prefix.

src/proto/insexpand.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ int ins_complete(int c, int enable_pum);
7777
void ins_compl_enable_autocomplete(void);
7878
void free_insexpand_stuff(void);
7979
void f_preinserted(typval_T *argvars, typval_T *rettv);
80+
int ins_compl_is_match_selected(void);
8081
/* vim: set ft=c : */

src/testdir/test_ins_complete.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6036,4 +6036,25 @@ func Test_autocompletedelay_longest_preinsert()
60366036
call StopVimInTerminal(buf)
60376037
endfunc
60386038

6039+
" Issue 18493
6040+
func Test_longest_preinsert_accept()
6041+
call test_override("char_avail", 1)
6042+
new
6043+
call setline(1, ['func1', 'xfunc', 'func2'])
6044+
set completeopt+=noselect
6045+
6046+
call feedkeys("Gof\<C-N>\<Down>\<C-Y>", 'tx')
6047+
call assert_equal('func1', getline('.'))
6048+
6049+
set completeopt+=longest autocomplete
6050+
call feedkeys("Sf\<Down>\<C-Y>", 'tx')
6051+
call assert_equal('func2', getline('.'))
6052+
call feedkeys("Sf\<C-Y>", 'tx')
6053+
call assert_equal('func', getline('.'))
6054+
6055+
set completeopt& autocomplete&
6056+
bw!
6057+
call test_override("char_avail", 0)
6058+
endfunc
6059+
60396060
" vim: shiftwidth=2 sts=2 expandtab nofoldenable

src/version.c

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

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1827,
732734
/**/
733735
1826,
734736
/**/

0 commit comments

Comments
 (0)