aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-25 08:02:52 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-26 08:06:32 +0800
commite6974114fb27a0076a6c887040e96de4a9dd509d (patch)
treef5656d0648b8737c5f6999968fa8c9d3ce1fdea2 /src/nvim/testdir
parentaf82eab946cf9f36e544b0591b8c8c02e8ddf316 (diff)
downloadrneovim-e6974114fb27a0076a6c887040e96de4a9dd509d.tar.gz
rneovim-e6974114fb27a0076a6c887040e96de4a9dd509d.tar.bz2
rneovim-e6974114fb27a0076a6c887040e96de4a9dd509d.zip
vim-patch:8.2.4760: using matchfuzzy() on a long list can take a while
Problem: Using matchfuzzy() on a long list can take a while. Solution: Add a limit to the number of matches. (Yasuhiro Matsumoto, closes vim/vim#10189) https://github.com/vim/vim/commit/9029a6e9931eede1d44f613687a2c01b9fe514ec
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_matchfuzzy.vim12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_matchfuzzy.vim b/src/nvim/testdir/test_matchfuzzy.vim
index abcc9b40c1..d53f8b0f4d 100644
--- a/src/nvim/testdir/test_matchfuzzy.vim
+++ b/src/nvim/testdir/test_matchfuzzy.vim
@@ -245,4 +245,16 @@ func Test_matchfuzzypos_mbyte()
call assert_equal([['xффйд'], [[2, 3, 4]], [168]], matchfuzzypos(['xффйд'], 'фйд'))
endfunc
+" Test for matchfuzzy() with limit
+func Test_matchfuzzy_limit()
+ let x = ['1', '2', '3', '2']
+ call assert_equal(['2', '2'], x->matchfuzzy('2'))
+ call assert_equal(['2', '2'], x->matchfuzzy('2', #{}))
+ call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 0}))
+ call assert_equal(['2'], x->matchfuzzy('2', #{limit: 1}))
+ call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 2}))
+ call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 3}))
+ call assert_fails("call matchfuzzy(x, '2', #{limit: '2'})", 'E475:')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab