vim-patch:9.1.0484: Sorting of completeopt+=fuzzy is not stable (#29338)

Problem:  Sorting of completeopt+=fuzzy is not stable.
Solution: Compare original indexes when scores are the same.
          (zeertzjq)

closes: vim/vim#14988

8e56747fd2
This commit is contained in:
zeertzjq
2024-06-15 04:33:19 +08:00
committed by GitHub
parent aa47af7e69
commit fd950d4998
3 changed files with 29 additions and 3 deletions

View File

@@ -2639,4 +2639,24 @@ func Test_complete_fuzzy_match()
unlet g:word
endfunc
" Check that tie breaking is stable for completeopt+=fuzzy (which should
" behave the same on different platforms).
func Test_complete_fuzzy_match_tie()
new
set completeopt+=fuzzy,noselect
call setline(1, ['aaabbccc', 'aaabbCCC', 'aaabbcccc', 'aaabbCCCC', ''])
call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-Y>", 'tx')
call assert_equal('aaabbccc', getline('.'))
call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-N>\<C-Y>", 'tx')
call assert_equal('aaabbCCC', getline('.'))
call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-N>\<C-N>\<C-Y>", 'tx')
call assert_equal('aaabbcccc', getline('.'))
call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-N>\<C-N>\<C-N>\<C-Y>", 'tx')
call assert_equal('aaabbCCCC', getline('.'))
bwipe!
set completeopt&
endfunc
" vim: shiftwidth=2 sts=2 expandtab nofoldenable