patch 9.1.0487: completed item not update on fuzzy completion

Commit: 
https://github.com/vim/vim/commit/f94c9c482a6dd488f0136ac99499eb6e2ab3ccca
Author: glepnir <glephun...@gmail.com>
Date:   Fri Jun 14 21:11:56 2024 +0200

    patch 9.1.0487: completed item not update on fuzzy completion
    
    Problem:  completed item not update on fuzzy completion
    Solution: reset compl_shown_match when at original match position
              (glepnir)
    
    closes: #14955
    
    Signed-off-by: glepnir <glephun...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/insexpand.c b/src/insexpand.c
index fafa7a2f0..7b9a5116d 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -1222,6 +1222,7 @@ ins_compl_build_pum(void)
 {
     compl_T     *compl;
     compl_T     *shown_compl = NULL;
+    compl_T     *after_first_compl = NULL;
     int                did_find_shown_match = FALSE;
     int                shown_match_ok = FALSE;
     int                i;
@@ -1298,6 +1299,8 @@ ins_compl_build_pum(void)
            }
            else if (compl_fuzzy_match)
            {
+               if (i == 0)
+                   after_first_compl = compl;
                // Update the maximum fuzzy score and the shown match
                // if the current item's score is higher
                if (compl->cp_score > max_fuzzy_score)
@@ -1318,6 +1321,8 @@ ins_compl_build_pum(void)
                {
                    shown_match_ok = TRUE;
                    cur = 0;
+                   if (match_at_original_text(compl_shown_match))
+                     compl_shown_match = after_first_compl;
                }
            }
 
diff --git a/src/testdir/test_ins_complete.vim 
b/src/testdir/test_ins_complete.vim
index c2cc484c8..9f689fefe 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -2559,6 +2559,13 @@ func Test_complete_fuzzy_match()
   call feedkeys("S\<C-x>\<C-o>fb\<C-p>\<C-p>\<C-p>\<C-p>", 'tx')
   call assert_equal('fooBaz', g:word)
 
+  func Comp()
+    call complete(col('.'), ["fooBaz", "foobar", "foobala"])
+    return ''
+  endfunc
+  call feedkeys("i\<C-R>=Comp()\<CR>", 'tx')
+  call assert_equal('fooBaz', g:word)
+
   " respect noselect
   set completeopt+=noselect
   call feedkeys("S\<C-x>\<C-o>fb", 'tx')
@@ -2574,6 +2581,7 @@ func Test_complete_fuzzy_match()
   augroup! AAAAA_Group
   delfunc OnPumChange
   delfunc Omni_test
+  delfunc Comp
   unlet g:item
   unlet g:word
 endfunc
diff --git a/src/version.c b/src/version.c
index 1035b606d..1a2f5d75c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    487,
 /**/
     486,
 /**/

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1sICOQ-00D0W4-Pa%40256bit.org.

Raspunde prin e-mail lui