patch 9.1.1827: completion: v9.1.1797 broke Ctrl-Y behaviour
Commit:
https://github.com/vim/vim/commit/f3d0d089074c4517b26ea3d2253eaae36c6212eb
Author: Girish Palya <[email protected]>
Date: Sun Oct 5 13:14:10 2025 +0000
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]>
diff --git a/src/edit.c b/src/edit.c
index d564e2c9e..c544df46f 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -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())
diff --git a/src/insexpand.c b/src/insexpand.c
index 38b209563..40ba81866 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -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.
diff --git a/src/proto/insexpand.pro b/src/proto/insexpand.pro
index 31d1ccb35..bff291171 100644
--- a/src/proto/insexpand.pro
+++ b/src/proto/insexpand.pro
@@ -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 : */
diff --git a/src/testdir/test_ins_complete.vim
b/src/testdir/test_ins_complete.vim
index c2465030d..a340d476e 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 668003064..81368c1c9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1827,
/**/
1826,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1v5OoP-00DPkZ-Eq%40256bit.org.