]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0345: Wrong autoformatting with 'autocomplete' v9.2.0345
authorzeertzjq <zeertzjq@outlook.com>
Tue, 14 Apr 2026 16:48:55 +0000 (16:48 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 14 Apr 2026 16:48:55 +0000 (16:48 +0000)
Problem:  Wrong autoformatting with 'autocomplete'.
Solution: Don't trigger autoformatting when ending autocompletion
          without selecting an item (zeertzjq).

fixes:  #19954
closes: #19970

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/testdir/test_ins_complete.vim
src/version.c

index 3fade6cb160290a0c952e53cf871bb4367890d64..abdcafa7bf427681b3d2b4858aab1bd9dbab3c33 100644 (file)
@@ -2956,7 +2956,7 @@ ins_compl_stop(int c, int prev_mode, int retval)
            want_cindent = FALSE;       // don't do it again
        }
     }
-    else
+    else if (!compl_autocomplete || compl_used_match)
     {
        int prev_col = curwin->w_cursor.col;
 
index bf16a936173a1b4e51dbee2db0ca81e6aca8ae54..a32bc45ccabe4926a0e388452e4c46b69beb43aa 100644 (file)
@@ -6289,4 +6289,20 @@ func Test_ins_register_preinsert_autocomplete()
   delfunc TestOmni
 endfunc
 
+func Test_autocomplete_with_auto_format()
+  call test_override("char_avail", 1)
+  new
+  setlocal formatoptions=tcq textwidth=9 autocomplete noautoindent
+  call feedkeys("ia b c d\<Esc>ie f g\<Esc>", 'tx')
+  call assert_equal(['a b c e f', 'gd'], getline(1, '$'))
+
+  %delete
+  setlocal autoindent
+  call feedkeys("ia b c d\<Esc>ie f g\<Esc>", 'tx')
+  call assert_equal(['a b c e f', 'gd'], getline(1, '$'))
+
+  bw!
+  call test_override("char_avail", 0)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
index 1694045111334a3d5c1613899e6f947ce1684ec4..f9899cb4fcecc4bfb9d609aa9ac987c0120e658d 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    345,
 /**/
     344,
 /**/