From fd950d4998a497cb4258d35af72408105900296a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Jun 2024 04:33:19 +0800 Subject: 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 https://github.com/vim/vim/commit/8e56747fd26b3b040b6fcbfb6be41b7d5922c6b5 --- test/old/testdir/test_ins_complete.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index fd77da67f8..ac08da9743 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -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\\ab\\", 'tx') + call assert_equal('aaabbccc', getline('.')) + call feedkeys("Gcc\\ab\\\", 'tx') + call assert_equal('aaabbCCC', getline('.')) + call feedkeys("Gcc\\ab\\\\", 'tx') + call assert_equal('aaabbcccc', getline('.')) + call feedkeys("Gcc\\ab\\\\\", 'tx') + call assert_equal('aaabbCCCC', getline('.')) + + bwipe! + set completeopt& +endfunc + " vim: shiftwidth=2 sts=2 expandtab nofoldenable -- cgit