mirror of
https://github.com/vim/vim.git
synced 2025-10-15 07:14:09 -04:00
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 <girishji@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
a76ea52a48
commit
f3d0d08907
@@ -693,12 +693,15 @@ edit(
|
||||
&& stop_arrow() == OK)
|
||||
{
|
||||
ins_compl_delete();
|
||||
ins_compl_insert(FALSE, !ins_compl_has_preinsert());
|
||||
if (ins_compl_preinsert_longest())
|
||||
if (ins_compl_preinsert_longest()
|
||||
&& !ins_compl_is_match_selected())
|
||||
{
|
||||
ins_compl_insert(FALSE, TRUE);
|
||||
ins_compl_init_get_longest();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
ins_compl_insert(FALSE, FALSE);
|
||||
}
|
||||
// Delete preinserted text when typing special chars
|
||||
else if (IS_WHITE_NL_OR_NUL(c) && ins_compl_preinsert_effect())
|
||||
|
@@ -853,6 +853,15 @@ is_nearest_active(void)
|
||||
&& !(flags & COT_FUZZY);
|
||||
}
|
||||
|
||||
/*
|
||||
* TRUE if a match is selected (even if it is not inserted).
|
||||
*/
|
||||
int
|
||||
ins_compl_is_match_selected(void)
|
||||
{
|
||||
return compl_shown_match != NULL && !is_first_match(compl_shown_match);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if autocomplete is active and the pre-insert effect targets the
|
||||
* longest prefix.
|
||||
|
@@ -77,4 +77,5 @@ int ins_complete(int c, int enable_pum);
|
||||
void ins_compl_enable_autocomplete(void);
|
||||
void free_insexpand_stuff(void);
|
||||
void f_preinserted(typval_T *argvars, typval_T *rettv);
|
||||
int ins_compl_is_match_selected(void);
|
||||
/* vim: set ft=c : */
|
||||
|
@@ -6036,4 +6036,25 @@ func Test_autocompletedelay_longest_preinsert()
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
" Issue 18493
|
||||
func Test_longest_preinsert_accept()
|
||||
call test_override("char_avail", 1)
|
||||
new
|
||||
call setline(1, ['func1', 'xfunc', 'func2'])
|
||||
set completeopt+=noselect
|
||||
|
||||
call feedkeys("Gof\<C-N>\<Down>\<C-Y>", 'tx')
|
||||
call assert_equal('func1', getline('.'))
|
||||
|
||||
set completeopt+=longest autocomplete
|
||||
call feedkeys("Sf\<Down>\<C-Y>", 'tx')
|
||||
call assert_equal('func2', getline('.'))
|
||||
call feedkeys("Sf\<C-Y>", 'tx')
|
||||
call assert_equal('func', getline('.'))
|
||||
|
||||
set completeopt& autocomplete&
|
||||
bw!
|
||||
call test_override("char_avail", 0)
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
||||
|
@@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1827,
|
||||
/**/
|
||||
1826,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user