patch 9.1.1657: Autocompletion adds delay

Commit: 
https://github.com/vim/vim/commit/196c376682f9ebad0d13a8d5458accfb33372537
Author: Girish Palya <[email protected]>
Date:   Wed Aug 20 21:15:06 2025 +0200

    patch 9.1.1657: Autocompletion adds delay
    
    Problem:  Autocompletion adds delay
              (gcanat, char101, after v9.1.1638)
    Solution: Temporarily disable autocomplation (Girish Palya).
    
    related: #17960
    fixes: #18022
    closes: #18048
    
    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 5974f244a..5ffe425d1 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -664,6 +664,9 @@ edit(
                    continue;
                }
 
+               if (p_ac)
+                   ins_compl_set_autocomplete(TRUE);
+
                // A non-white character that fits in with the current
                // completion: Add to "compl_leader".
                if (ins_compl_accept_char(c))
@@ -685,6 +688,9 @@ edit(
                    continue;
                }
 
+               if (p_ac)
+                   ins_compl_set_autocomplete(FALSE);
+
                // Pressing CTRL-Y selects the current match.  When
                // ins_compl_enter_selects() is set the Enter key does the
                // same.
@@ -987,10 +993,11 @@ doESCkey:
                    && curwin->w_cursor.col > 0)
            {
                c = char_before_cursor();
-               if (ins_compl_setup_autocompl(c))
+               if (vim_isprintc(c))
                {
                    update_screen(UPD_VALID); // Show char deletion immediately
                    out_flush();
+                   ins_compl_set_autocomplete(TRUE);
                    goto docomplete; // Trigger autocompletion
                }
            }
@@ -1413,10 +1420,11 @@ normalchar:
            foldOpenCursor();
 #endif
            // Trigger autocompletion
-           if (p_ac && !char_avail() && ins_compl_setup_autocompl(c))
+           if (p_ac && !char_avail() && vim_isprintc(c))
            {
                update_screen(UPD_VALID); // Show character immediately
                out_flush();
+               ins_compl_set_autocomplete(TRUE);
                goto docomplete;
            }
 
diff --git a/src/insexpand.c b/src/insexpand.c
index 85284f2c6..9ff36ab99 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -7088,7 +7088,10 @@ ins_complete(int c, int enable_pum)
     if (!compl_started)
     {
        if (ins_compl_start() == FAIL)
+       {
+           compl_autocomplete = FALSE;
            return FAIL;
+       }
     }
     else if (insert_match && stop_arrow() == FAIL)
        return FAIL;
@@ -7175,25 +7178,20 @@ ins_complete(int c, int enable_pum)
 
     compl_was_interrupted = compl_interrupted;
     compl_interrupted = FALSE;
+    compl_autocomplete = FALSE;
 
     return OK;
 }
 
 /*
- * Returns TRUE if the given character 'c' can be used to trigger
- * autocompletion.
+ * Enable/disable autocompletion
  */
-    int
-ins_compl_setup_autocompl(int c)
+    void
+ins_compl_set_autocomplete(int value)
 {
 #ifdef ELAPSED_FUNC
-    if (vim_isprintc(c))
-    {
-       compl_autocomplete = TRUE;
-       return TRUE;
-    }
+    compl_autocomplete = value;
 #endif
-    return FALSE;
 }
 
 /*
diff --git a/src/proto/insexpand.pro b/src/proto/insexpand.pro
index bc57e0e87..16f073ed8 100644
--- a/src/proto/insexpand.pro
+++ b/src/proto/insexpand.pro
@@ -72,6 +72,6 @@ void ins_compl_delete(void);
 void ins_compl_insert(int move_cursor);
 void ins_compl_check_keys(int frequency, int in_compl_func);
 int ins_complete(int c, int enable_pum);
-int ins_compl_setup_autocompl(int c);
+void ins_compl_set_autocomplete(int val);
 void free_insexpand_stuff(void);
 /* vim: set ft=c : */
diff --git a/src/testdir/dumps/Test_autocompletedelay_10.dump 
b/src/testdir/dumps/Test_autocompletedelay_10.dump
new file mode 100644
index 000000000..c404578cf
--- /dev/null
+++ b/src/testdir/dumps/Test_autocompletedelay_10.dump
@@ -0,0 +1,10 @@
+|f+0&#ffffff0|o@1| @71
+|f|o@1|b|a|r| @68
+|f|o@1|b|a|r|b|a|z| @65
+|f> @73
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@62
diff --git a/src/testdir/dumps/Test_autocompletedelay_8.dump 
b/src/testdir/dumps/Test_autocompletedelay_8.dump
new file mode 100644
index 000000000..3ef597aa4
--- /dev/null
+++ b/src/testdir/dumps/Test_autocompletedelay_8.dump
@@ -0,0 +1,10 @@
+|f+0&#ffffff0|o@1| @71
+|f|o@1|b|a|r| @68
+|f|o@1|b|a|r|b|a|z| @65
+|f|o@1|b|a|r|b|a|z> @65
+|f+0#0000001#e0e0e08|o@1|b|a|r|b|a|z| @5| +0#4040ff13#ffffff0@59
+|f+0#0000001#ffd7ff255|o@1|b|a|r| @8| +0#4040ff13#ffffff0@59
+|f+0#0000001#ffd7ff255|o@1| @11| +0#4040ff13#ffffff0@59
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@62
diff --git a/src/testdir/dumps/Test_autocompletedelay_9.dump 
b/src/testdir/dumps/Test_autocompletedelay_9.dump
new file mode 100644
index 000000000..cb3c3c1f9
--- /dev/null
+++ b/src/testdir/dumps/Test_autocompletedelay_9.dump
@@ -0,0 +1,10 @@
+|f+0&#ffffff0|o@1| @71
+|f|o@1|b|a|r| @68
+|f|o@1|b|a|r|b|a|z| @65
+|f|o@1|b|a|r|b|a|z> @65
+|f+0#0000001#ffd7ff255|o@1|b|a|r|b|a|z| @5| +0#4040ff13#ffffff0@59
+|f+0#0000001#e0e0e08|o@1|b|a|r| @8| +0#4040ff13#ffffff0@59
+|f+0#0000001#ffd7ff255|o@1| @11| +0#4040ff13#ffffff0@59
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@62
diff --git a/src/testdir/test_ins_complete.vim 
b/src/testdir/test_ins_complete.vim
index f3ea3a29f..4cbdec6ff 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -5358,7 +5358,7 @@ func Test_autocomplete_timer()
   call assert_equal(['abc', 'ab'], b:matches->mapnew('v:val.word'))
   call assert_equal(0, b:selected)
   call assert_equal(1, g:CallCount)
-  call assert_equal('abc', getline(4))
+  call assert_equal('ab', getline(4))
   set completeopt&
 
   " Test 8: {func} completes after space, but not '.'
@@ -5490,6 +5490,20 @@ func Test_autocompletedelay()
   call term_sendkeys(buf, "Sf\<C-N>")
   call VerifyScreenDump(buf, 'Test_autocompletedelay_7', {})
 
+  " After the menu is open, ^N/^P and Up/Down should not delay
+  call term_sendkeys(buf, "\<Esc>:set completeopt=menu noruler\<CR>")
+  call term_sendkeys(buf, "\<Esc>Sf")
+  sleep 500ms
+  call term_sendkeys(buf, "\<C-N>")
+  call VerifyScreenDump(buf, 'Test_autocompletedelay_8', {})
+  call term_sendkeys(buf, "\<Down>")
+  call VerifyScreenDump(buf, 'Test_autocompletedelay_9', {})
+
+  " When menu is not open Up/Down moves cursor to different line
+  call term_sendkeys(buf, "\<Esc>Sf")
+  call term_sendkeys(buf, "\<Down>")
+  call VerifyScreenDump(buf, 'Test_autocompletedelay_10', {})
+
   call term_sendkeys(buf, "\<esc>")
   call StopVimInTerminal(buf)
 endfunc
diff --git a/src/version.c b/src/version.c
index 5afb71eaf..2a4cd7515 100644
--- a/src/version.c
+++ b/src/version.c
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1657,
 /**/
     1656,
 /**/

-- 
-- 
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/E1uooVY-009RPa-BC%40256bit.org.

Raspunde prin e-mail lui