patch 9.2.0380: completion: a few issues in completion code

Commit: 
https://github.com/vim/vim/commit/b328686d6a1eae1c519a0cdc0420c0d87b6d1fd1
Author: glepnir <[email protected]>
Date:   Mon Apr 20 17:36:56 2026 +0000

    patch 9.2.0380: completion: a few issues in completion code
    
    Problem: ins_compl_stop() sets compl_best_matches = 0, but that's a
             pointer, should reset compl_num_bests instead,
             find_common_prefix() reads cpt_sources_array[cur_source] without
             checking cur_source != -1 which causes an OOB for -1,
             find_next_completion_match(): second `if` in the pending loop
             should be `else if`. Forward paging only moves one step per call.
    
    Solution: Reset compl_num_bests instead, add a check for cur_source not
              equal -1, change if to else if (glepnir)
    
    closes: #20000
    
    Signed-off-by: glepnir <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/insexpand.c b/src/insexpand.c
index 019557cab..0019c7eb4 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -3034,7 +3034,7 @@ ins_compl_stop(int c, int prev_mode, int retval)
     }
     compl_autocomplete = FALSE;
     compl_from_nonkeyword = FALSE;
-    compl_best_matches = 0;
+    compl_num_bests = 0;
     compl_ins_end_col = 0;
 
     if (c == Ctrl_C && cmdwin_type != 0)
@@ -5795,7 +5795,8 @@ find_common_prefix(size_t *prefix_len, int curbuf_only)
            }
 
            if (!match_limit_exceeded && (!curbuf_only
-                       || cpt_sources_array[cur_source].cs_flag == '.'))
+                       || (cur_source != -1
+                           && cpt_sources_array[cur_source].cs_flag == '.')))
            {
                if (first == NULL && STRNCMP(ins_compl_leader(),
                            compl->cp_str.string, ins_compl_leader_len()) == 0)
@@ -6076,7 +6077,7 @@ find_next_completion_match(
                    compl_shown_match = compl_shown_match->cp_next;
                    --compl_pending;
                }
-               if (compl_pending < 0 && compl_shown_match->cp_prev != NULL)
+               else if (compl_pending < 0 && compl_shown_match->cp_prev != 
NULL)
                {
                    compl_shown_match = compl_shown_match->cp_prev;
                    ++compl_pending;
diff --git a/src/version.c b/src/version.c
index d2d4b141c..ddac9aa6d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    380,
 /**/
     379,
 /**/

-- 
-- 
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/E1wEsgB-00CVOF-SN%40256bit.org.

Raspunde prin e-mail lui