patch 9.1.1107: cannot loop through completion menu with fuzzy

Commit: 
https://github.com/vim/vim/commit/c0b7ca406ba18640c56e2746d6f6d03549d53072
Author: glepnir <glephun...@gmail.com>
Date:   Thu Feb 13 20:27:44 2025 +0100

    patch 9.1.1107: cannot loop through completion menu with fuzzy
    
    Problem:  cannot loop through completion menu with fuzzy and nosort in
              'completeopt'
              (Tomasz N)
    Solution: Reset cur to zero and update compl_shown_match when
              'completeopt' contains "nosort" but not "noselect"
              (glepnir)
    
    fixes: #16624
    closes: #16629
    
    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 85b32691d..7d04690c5 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -1367,8 +1367,6 @@ ins_compl_build_pum(void)
                    if (!compl_no_select)
                        compl_shown_match = compl;
                }
-               else if (!fuzzy_sort && i == 0 && !compl_no_select)
-                   compl_shown_match = shown_compl;
 
                if (!shown_match_ok && compl == compl_shown_match && 
!compl_no_select)
                {
@@ -1402,6 +1400,13 @@ ins_compl_build_pum(void)
     if (compl_match_arraysize == 0)
        return -1;
 
+    if (fuzzy_filter && !fuzzy_sort && !compl_no_select && !shown_match_ok)
+    {
+       compl_shown_match = shown_compl;
+       shown_match_ok = TRUE;
+       cur = 0;
+    }
+
     compl_match_array = ALLOC_CLEAR_MULT(pumitem_T, compl_match_arraysize);
     if (compl_match_array == NULL)
        return -1;
diff --git a/src/testdir/test_ins_complete.vim 
b/src/testdir/test_ins_complete.vim
index 5d24d51d6..ac400a2e7 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -2689,6 +2689,8 @@ func Test_complete_fuzzy_match()
   func OnPumChange()
     let g:item = get(v:event, 'completed_item', {})
     let g:word = get(g:item, 'word', v:null)
+    let g:abbr = get(g:item, 'abbr', v:null)
+    let g:selected = get(complete_info(['selected']), 'selected')
   endfunction
 
   augroup AAAAA_Group
@@ -2875,6 +2877,20 @@ func Test_complete_fuzzy_match()
   call feedkeys("S\<C-x>\<C-o>fooB\<C-Y>", 'tx')
   call assert_equal('fooBaz', getline('.'))
 
+  set cot=menuone,fuzzy,nosort
+  func CompAnother()
+    call complete(col('.'), [#{word: "do" }, #{word: "echo"}, #{word: "for 
(${1:expr1}, ${2:expr2}, ${3:expr3}) {
        $0
}", abbr: "for" }, #{word: "foo"}])
+    return ''
+  endfunc
+  call feedkeys("i\<C-R>=CompAnother()\<CR>\<C-N>\<C-N>", 'tx')
+  call assert_equal("for", g:abbr)
+  call assert_equal(2, g:selected)
+
+  set cot+=noinsert
+  call feedkeys("i\<C-R>=CompAnother()\<CR>f", 'tx')
+  call assert_equal("for", g:abbr)
+  call assert_equal(2, g:selected)
+
   " clean up
   set omnifunc=
   bw!
@@ -2885,8 +2901,11 @@ func Test_complete_fuzzy_match()
   delfunc OnPumChange
   delfunc Omni_test
   delfunc Comp
+  delfunc CompAnother
   unlet g:item
   unlet g:word
+  unlet g:selected
+  unlet g:abbr
 endfunc
 
 func Test_complete_fuzzy_with_completeslash()
diff --git a/src/version.c b/src/version.c
index f17944a7a..418fcb7ec 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 */
+/**/
+    1107,
 /**/
     1106,
 /**/

-- 
-- 
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 visit 
https://groups.google.com/d/msgid/vim_dev/E1tif8x-0070QA-GH%40256bit.org.

Raspunde prin e-mail lui