mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.1107: cannot loop through completion menu with fuzzy (#32438)
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: vim/vim#16624
closes: vim/vim#16629
c0b7ca406b
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
parent
478c71f03c
commit
f247402010
@ -1295,8 +1295,6 @@ static int ins_compl_build_pum(void)
|
|||||||
if (!compl_no_select) {
|
if (!compl_no_select) {
|
||||||
compl_shown_match = comp;
|
compl_shown_match = comp;
|
||||||
}
|
}
|
||||||
} else if (!fuzzy_sort && i == 0 && !compl_no_select) {
|
|
||||||
compl_shown_match = shown_compl;
|
|
||||||
}
|
}
|
||||||
if (!shown_match_ok && comp == compl_shown_match && !compl_no_select) {
|
if (!shown_match_ok && comp == compl_shown_match && !compl_no_select) {
|
||||||
cur = i;
|
cur = i;
|
||||||
@ -1327,6 +1325,12 @@ static int ins_compl_build_pum(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fuzzy_filter && !fuzzy_sort && !compl_no_select && !shown_match_ok) {
|
||||||
|
compl_shown_match = shown_compl;
|
||||||
|
shown_match_ok = true;
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
|
|
||||||
assert(compl_match_arraysize >= 0);
|
assert(compl_match_arraysize >= 0);
|
||||||
compl_match_array = xcalloc((size_t)compl_match_arraysize, sizeof(pumitem_T));
|
compl_match_array = xcalloc((size_t)compl_match_arraysize, sizeof(pumitem_T));
|
||||||
|
|
||||||
|
@ -2767,6 +2767,8 @@ func Test_complete_fuzzy_match()
|
|||||||
func OnPumChange()
|
func OnPumChange()
|
||||||
let g:item = get(v:event, 'completed_item', {})
|
let g:item = get(v:event, 'completed_item', {})
|
||||||
let g:word = get(g:item, 'word', v:null)
|
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
|
endfunction
|
||||||
|
|
||||||
augroup AAAAA_Group
|
augroup AAAAA_Group
|
||||||
@ -2857,6 +2859,20 @@ func Test_complete_fuzzy_match()
|
|||||||
call feedkeys("S\<C-x>\<C-o>fooB\<C-Y>", 'tx')
|
call feedkeys("S\<C-x>\<C-o>fooB\<C-Y>", 'tx')
|
||||||
call assert_equal('fooBaz', getline('.'))
|
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}) {\n\t$0\n}", 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
|
" clean up
|
||||||
set omnifunc=
|
set omnifunc=
|
||||||
bw!
|
bw!
|
||||||
@ -2866,8 +2882,11 @@ func Test_complete_fuzzy_match()
|
|||||||
delfunc OnPumChange
|
delfunc OnPumChange
|
||||||
delfunc Omni_test
|
delfunc Omni_test
|
||||||
delfunc Comp
|
delfunc Comp
|
||||||
|
delfunc CompAnother
|
||||||
unlet g:item
|
unlet g:item
|
||||||
unlet g:word
|
unlet g:word
|
||||||
|
unlet g:selected
|
||||||
|
unlet g:abbr
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Check that tie breaking is stable for completeopt+=fuzzy (which should
|
" Check that tie breaking is stable for completeopt+=fuzzy (which should
|
||||||
|
Loading…
Reference in New Issue
Block a user