Skip to content

Commit c0b7ca4

Browse files
glepnirchrisbra
authored andcommitted
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 4f010c9 commit c0b7ca4

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/insexpand.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,8 +1367,6 @@ ins_compl_build_pum(void)
13671367
if (!compl_no_select)
13681368
compl_shown_match = compl;
13691369
}
1370-
else if (!fuzzy_sort && i == 0 && !compl_no_select)
1371-
compl_shown_match = shown_compl;
13721370

13731371
if (!shown_match_ok && compl == compl_shown_match && !compl_no_select)
13741372
{
@@ -1402,6 +1400,13 @@ ins_compl_build_pum(void)
14021400
if (compl_match_arraysize == 0)
14031401
return -1;
14041402

1403+
if (fuzzy_filter && !fuzzy_sort && !compl_no_select && !shown_match_ok)
1404+
{
1405+
compl_shown_match = shown_compl;
1406+
shown_match_ok = TRUE;
1407+
cur = 0;
1408+
}
1409+
14051410
compl_match_array = ALLOC_CLEAR_MULT(pumitem_T, compl_match_arraysize);
14061411
if (compl_match_array == NULL)
14071412
return -1;

src/testdir/test_ins_complete.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,8 @@ func Test_complete_fuzzy_match()
26892689
func OnPumChange()
26902690
let g:item = get(v:event, 'completed_item', {})
26912691
let g:word = get(g:item, 'word', v:null)
2692+
let g:abbr = get(g:item, 'abbr', v:null)
2693+
let g:selected = get(complete_info(['selected']), 'selected')
26922694
endfunction
26932695

26942696
augroup AAAAA_Group
@@ -2875,6 +2877,20 @@ func Test_complete_fuzzy_match()
28752877
call feedkeys("S\<C-x>\<C-o>fooB\<C-Y>", 'tx')
28762878
call assert_equal('fooBaz', getline('.'))
28772879

2880+
set cot=menuone,fuzzy,nosort
2881+
func CompAnother()
2882+
call complete(col('.'), [#{word: "do" }, #{word: "echo"}, #{word: "for (${1:expr1}, ${2:expr2}, ${3:expr3}) {\n\t$0\n}", abbr: "for" }, #{word: "foo"}])
2883+
return ''
2884+
endfunc
2885+
call feedkeys("i\<C-R>=CompAnother()\<CR>\<C-N>\<C-N>", 'tx')
2886+
call assert_equal("for", g:abbr)
2887+
call assert_equal(2, g:selected)
2888+
2889+
set cot+=noinsert
2890+
call feedkeys("i\<C-R>=CompAnother()\<CR>f", 'tx')
2891+
call assert_equal("for", g:abbr)
2892+
call assert_equal(2, g:selected)
2893+
28782894
" clean up
28792895
set omnifunc=
28802896
bw!
@@ -2885,8 +2901,11 @@ func Test_complete_fuzzy_match()
28852901
delfunc OnPumChange
28862902
delfunc Omni_test
28872903
delfunc Comp
2904+
delfunc CompAnother
28882905
unlet g:item
28892906
unlet g:word
2907+
unlet g:selected
2908+
unlet g:abbr
28902909
endfunc
28912910

28922911
func Test_complete_fuzzy_with_completeslash()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1107,
707709
/**/
708710
1106,
709711
/**/

0 commit comments

Comments
 (0)