comparison src/testdir/test_functions.vim @ 22355:0491b9cafd44 v8.2.1726

patch 8.2.1726: fuzzy matching only works on strings Commit: https://github.com/vim/vim/commit/4f73b8e9cc83f647b34002554a8bdf9abec0a82f Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 22 20:33:50 2020 +0200 patch 8.2.1726: fuzzy matching only works on strings Problem: Fuzzy matching only works on strings. Solution: Support passing a dict. Add matchfuzzypos() to also get the match positions. (Yegappan Lakshmanan, closes #6947)
author Bram Moolenaar <Bram@vim.org>
date Tue, 22 Sep 2020 20:45:04 +0200
parents f22acf6472da
children 0e231e8e70f8
comparison
equal deleted inserted replaced
22354:19139cc50651 22355:0491b9cafd44
2552 func Test_browsedir() 2552 func Test_browsedir()
2553 CheckFeature browse 2553 CheckFeature browse
2554 call assert_fails('call browsedir("open", [])', 'E730:') 2554 call assert_fails('call browsedir("open", [])', 'E730:')
2555 endfunc 2555 endfunc
2556 2556
2557 " Test for matchfuzzy()
2558 func Test_matchfuzzy()
2559 call assert_fails('call matchfuzzy(10, "abc")', 'E714:')
2560 call assert_fails('call matchfuzzy(["abc"], [])', 'E730:')
2561 call assert_equal([], matchfuzzy([], 'abc'))
2562 call assert_equal([], matchfuzzy(['abc'], ''))
2563 call assert_equal(['abc'], matchfuzzy(['abc', 10], 'ac'))
2564 call assert_equal([], matchfuzzy([10, 20], 'ac'))
2565 call assert_equal(['abc'], matchfuzzy(['abc'], 'abc'))
2566 call assert_equal(['crayon', 'camera'], matchfuzzy(['camera', 'crayon'], 'cra'))
2567 call assert_equal(['aabbaa', 'aaabbbaaa', 'aaaabbbbaaaa', 'aba'], matchfuzzy(['aba', 'aabbaa', 'aaabbbaaa', 'aaaabbbbaaaa'], 'aa'))
2568 call assert_equal(['one'], matchfuzzy(['one', 'two'], 'one'))
2569 call assert_equal(['oneTwo', 'onetwo'], matchfuzzy(['onetwo', 'oneTwo'], 'oneTwo'))
2570 call assert_equal(['one_two', 'onetwo'], matchfuzzy(['onetwo', 'one_two'], 'oneTwo'))
2571 call assert_equal(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], matchfuzzy(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'aa'))
2572 call assert_equal([], matchfuzzy([repeat('a', 300)], repeat('a', 257)))
2573
2574 %bw!
2575 eval ['somebuf', 'anotherone', 'needle', 'yetanotherone']->map({_, v -> bufadd(v) + bufload(v)})
2576 let l = getbufinfo()->map({_, v -> v.name})->matchfuzzy('ndl')
2577 call assert_equal(1, len(l))
2578 call assert_match('needle', l[0])
2579 endfunc
2580
2581 " vim: shiftwidth=2 sts=2 expandtab 2557 " vim: shiftwidth=2 sts=2 expandtab