]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1800: completion: strange behaviour with 'ac' completeopt=longest,preinsert v9.1.1800
authorGirish Palya <girishji@gmail.com>
Sun, 28 Sep 2025 17:12:55 +0000 (17:12 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 28 Sep 2025 17:12:55 +0000 (17:12 +0000)
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 <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/testdir/dumps/Test_autocompletedelay_7.dump
src/testdir/test_ins_complete.vim
src/version.c

index 2aabacd83aa7fb9e1779accd5ada166a06b58df5..35068cdae606c2c42a504c19dcf6ecf2e7571699 100644 (file)
@@ -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;
     }
 
index 08f4059c68ff7d03fc7519c4031d6e193c5eb8ab..017156bd0d32d41aef2d75d423f50c51bbe8eb79 100644 (file)
@@ -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
index 48623f26a740536fd1120d9e1dc9af38545766fd..e6abe98e4a6a9504d455a9b960653e859419ab7c 100644 (file)
@@ -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
index 5c1424ed323a04fa4dfb5cf592211544ab0aaf85..1faf29ad3cbeab95b1b79ae89481d5afd93846df 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1800,
 /**/
     1799,
 /**/