&& 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())
&& !(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.
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 : */
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1827,
/**/
1826,
/**/