patch 9.1.1800: completion: strange behaviour with 'ac' completeopt=longest,preinsert
Commit: https://github.com/vim/vim/commit/d35e5e4237ec578962d3d577bc5a4e4f6bf4abb2 Author: Girish Palya <[email protected]> Date: Sun Sep 28 17:12:55 2025 +0000 patch 9.1.1800: completion: strange behaviour with 'ac' completeopt=longest,preinsert Problem: completion: strange behaviour with 'ac' completeopt=longest,preinsert (zeertzjq) Solution: Let preinsert take precedence (Girish Palya) fixes: #18410 closes: #18428 Signed-off-by: Girish Palya <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/insexpand.c b/src/insexpand.c index 2aabacd83..35068cdae 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -3100,7 +3100,8 @@ ins_compl_prep(int c) if (ctrl_x_mode_not_defined_yet() || (ctrl_x_mode_normal() && !compl_started)) { - compl_get_longest = (get_cot_flags() & COT_LONGEST) != 0; + compl_get_longest = (get_cot_flags() & COT_LONGEST) + && !ins_compl_has_autocomplete(); compl_used_match = TRUE; } diff --git a/src/testdir/dumps/Test_autocompletedelay_7.dump b/src/testdir/dumps/Test_autocompletedelay_7.dump index 08f4059c6..017156bd0 100644 --- a/src/testdir/dumps/Test_autocompletedelay_7.dump +++ b/src/testdir/dumps/Test_autocompletedelay_7.dump @@ -2,9 +2,9 @@ |f|o@1|b|a|r| @68 |f|o@1|b|a|r|b|a|z| @65 |f|o@1> @71 -|f+0#0000001#ffd7ff255|o@1| @11| +0#4040ff13#ffffff0@59 +|f+0#0000001#e0e0e08|o@1| @11| +0#4040ff13#ffffff0@59 |f+0#0000001#ffd7ff255|o@1|b|a|r| @8| +0#4040ff13#ffffff0@59 |f+0#0000001#ffd7ff255|o@1|b|a|r|b|a|z| @5| +0#4040ff13#ffffff0@59 |~| @73 |~| @73 -|-+2#0000000&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |B+0#e000002&|a|c|k| |a|t| |o|r|i|g|i|n|a|l| +0#0000000&@29 +|-+2#0000000&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |3| +0#0000000&@33 diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 48623f26a..e6abe98e4 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -5721,7 +5721,7 @@ func Test_autocompletedelay() call VerifyScreenDump(buf, 'Test_autocompletedelay_6', {}) " During delay wait, user can open menu using CTRL_N completion - call term_sendkeys(buf, "\<Esc>:set completeopt=menuone,longest\<CR>") + call term_sendkeys(buf, "\<Esc>:set completeopt=menuone\<CR>") call term_sendkeys(buf, "Sf\<C-N>") call VerifyScreenDump(buf, 'Test_autocompletedelay_7', {}) @@ -5871,6 +5871,16 @@ func Test_autocomplete_longest() call feedkeys("Go\<ESC>", 'tx') call DoTest("f\<C-N>\<C-N>\<BS>\<BS>\<BS>\<BS>", 'foo', 3) + " Issue #18410: When both 'preinsert' and 'longest' are set, 'preinsert' + " takes precedence + %delete + set autocomplete completeopt+=longest,preinsert + call setline(1, ['foobar', 'foofoo', 'foobaz', '']) + call feedkeys("G", 'tx') + call DoTest("f", 'foobar', 2) + call assert_equal(1, g:preinserted) + + " Undo %delete _ let &l:undolevels = &l:undolevels normal! ifoo diff --git a/src/version.c b/src/version.c index 5c1424ed3..1faf29ad3 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 */ +/**/ + 1800, /**/ 1799, /**/ -- -- 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/E1v2vDr-00HA4y-Jq%40256bit.org.
