vim-patch:9.2.1007: fuzzy completion list wrongly sorted after complete() (#41498)

Problem:  With 'completeopt' "fuzzy", a re-sort after complete() leaves the
          last match unsorted at the end of the list.
Solution: Find the original text by its flag instead of assuming
          compl_shows_dir points at it.

closes: vim/vim#21103

7e74722999
This commit is contained in:
glepnir
2026-08-26 12:32:09 +08:00
committed by GitHub
parent 35ae925da9
commit f97bcbdf77
2 changed files with 50 additions and 15 deletions

View File

@@ -6851,4 +6851,21 @@ func Test_complete_info_hlgroup()
bwipe!
endfunc
func Test_complete_fuzzy_resort()
new
set completeopt=menu,menuone,noselect,fuzzy
inoremap <buffer> <F5> <Cmd>call complete(1, ['xxxb', 'xb', 'b'])<CR>
call feedkeys("i\<F5>b\<C-R>=string(map(complete_info(['items']).items, 'v:val.word'))\<CR>\<Esc>", 'tx')
call assert_equal("b['b', 'xb', 'xxxb']", getline(1))
%d _
call setline(1, ['xxxbar', 'xbar', 'bar'])
call feedkeys("Go\<C-P>b\<C-R>=string(map(complete_info(['items']).items, 'v:val.word'))\<CR>\<Esc>", 'tx')
call assert_equal("b['bar', 'xbar', 'xxxbar']", getline('$'))
bwipe!
set completeopt&
endfunc
" vim: shiftwidth=2 sts=2 expandtab nofoldenable