test_matchfuzzy.vim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. " Tests for fuzzy matching
  2. source shared.vim
  3. source check.vim
  4. source term_util.vim
  5. " Test for matchfuzzy()
  6. func Test_matchfuzzy()
  7. call assert_fails('call matchfuzzy(10, "abc")', 'E686:')
  8. call assert_fails('call matchfuzzy(["abc"], [])', 'E730:')
  9. call assert_fails("let x = matchfuzzy(v:_null_list, 'foo')", 'E686:')
  10. call assert_fails('call matchfuzzy(["abc"], v:_null_string)', 'E475:')
  11. call assert_equal([], matchfuzzy([], 'abc'))
  12. call assert_equal([], matchfuzzy(['abc'], ''))
  13. call assert_equal(['abc'], matchfuzzy(['abc', 10], 'ac'))
  14. call assert_equal([], matchfuzzy([10, 20], 'ac'))
  15. call assert_equal(['abc'], matchfuzzy(['abc'], 'abc'))
  16. call assert_equal(['crayon', 'camera'], matchfuzzy(['camera', 'crayon'], 'cra'))
  17. call assert_equal(['aabbaa', 'aaabbbaaa', 'aaaabbbbaaaa', 'aba'], matchfuzzy(['aba', 'aabbaa', 'aaabbbaaa', 'aaaabbbbaaaa'], 'aa'))
  18. call assert_equal(['one'], matchfuzzy(['one', 'two'], 'one'))
  19. call assert_equal(['oneTwo', 'onetwo'], matchfuzzy(['onetwo', 'oneTwo'], 'oneTwo'))
  20. call assert_equal(['onetwo', 'one_two'], matchfuzzy(['onetwo', 'one_two'], 'oneTwo'))
  21. call assert_equal(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], matchfuzzy(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'aa'))
  22. call assert_equal(256, matchfuzzy([repeat('a', 256)], repeat('a', 256))[0]->len())
  23. call assert_equal([], matchfuzzy([repeat('a', 300)], repeat('a', 257)))
  24. " matches with same score should not be reordered
  25. let l = ['abc1', 'abc2', 'abc3']
  26. call assert_equal(l, l->matchfuzzy('abc'))
  27. " Tests for match preferences
  28. " preference for camel case match
  29. call assert_equal(['oneTwo', 'onetwo'], ['onetwo', 'oneTwo']->matchfuzzy('onetwo'))
  30. " preference for match after a separator (_ or space)
  31. call assert_equal(['onetwo', 'one_two', 'one two'], ['onetwo', 'one_two', 'one two']->matchfuzzy('onetwo'))
  32. " preference for leading letter match
  33. call assert_equal(['onetwo', 'xonetwo'], ['xonetwo', 'onetwo']->matchfuzzy('onetwo'))
  34. " preference for sequential match
  35. call assert_equal(['onetwo', 'oanbectdweo'], ['oanbectdweo', 'onetwo']->matchfuzzy('onetwo'))
  36. " non-matching leading letter(s) penalty
  37. call assert_equal(['xonetwo', 'xxonetwo'], ['xxonetwo', 'xonetwo']->matchfuzzy('onetwo'))
  38. " total non-matching letter(s) penalty
  39. call assert_equal(['one', 'onex', 'onexx'], ['onexx', 'one', 'onex']->matchfuzzy('one'))
  40. " prefer complete matches over separator matches
  41. call assert_equal(['.vim/vimrc', '.vim/vimrc_colors', '.vim/v_i_m_r_c'], ['.vim/vimrc', '.vim/vimrc_colors', '.vim/v_i_m_r_c']->matchfuzzy('vimrc'))
  42. " gap penalty
  43. call assert_equal(['xxayybxxxx', 'xxayyybxxx', 'xxayyyybxx'], ['xxayyyybxx', 'xxayyybxxx', 'xxayybxxxx']->matchfuzzy('ab'))
  44. " path separator vs word separator
  45. call assert_equal(['color/setup.vim', 'color\\setup.vim', 'color setup.vim', 'color_setup.vim', 'colorsetup.vim'], matchfuzzy(['colorsetup.vim', 'color setup.vim', 'color/setup.vim', 'color_setup.vim', 'color\\setup.vim'], 'setup.vim'))
  46. " match multiple words (separated by space)
  47. call assert_equal(['foo bar baz'], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzy('baz foo'))
  48. call assert_equal([], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzy('one two'))
  49. call assert_equal([], ['foo bar']->matchfuzzy(" \t "))
  50. " test for matching a sequence of words
  51. call assert_equal(['bar foo'], ['foo bar', 'bar foo', 'foobar', 'barfoo']->matchfuzzy('bar foo', {'matchseq' : 1}))
  52. call assert_equal([#{text: 'two one'}], [#{text: 'one two'}, #{text: 'two one'}]->matchfuzzy('two one', #{key: 'text', matchseq: v:true}))
  53. %bw!
  54. eval ['somebuf', 'anotherone', 'needle', 'yetanotherone']->map({_, v -> bufadd(v) + bufload(v)})
  55. let l = getbufinfo()->map({_, v -> fnamemodify(v.name, ':t')})->matchfuzzy('ndl')
  56. call assert_equal(1, len(l))
  57. call assert_match('needle', l[0])
  58. " Test for fuzzy matching dicts
  59. let l = [{'id' : 5, 'val' : 'crayon'}, {'id' : 6, 'val' : 'camera'}]
  60. call assert_equal([{'id' : 6, 'val' : 'camera'}], matchfuzzy(l, 'cam', {'text_cb' : {v -> v.val}}))
  61. call assert_equal([{'id' : 6, 'val' : 'camera'}], matchfuzzy(l, 'cam', {'key' : 'val'}))
  62. call assert_equal([], matchfuzzy(l, 'day', {'text_cb' : {v -> v.val}}))
  63. call assert_equal([], matchfuzzy(l, 'day', {'key' : 'val'}))
  64. call assert_fails("let x = matchfuzzy(l, 'cam', 'random')", 'E1206:')
  65. call assert_equal([], matchfuzzy(l, 'day', {'text_cb' : {v -> []}}))
  66. call assert_equal([], matchfuzzy(l, 'day', {'text_cb' : {v -> 1}}))
  67. call assert_fails("let x = matchfuzzy(l, 'day', {'text_cb' : {a, b -> 1}})", 'E119:')
  68. call assert_equal([], matchfuzzy(l, 'cam'))
  69. " Nvim's callback implementation is different, so E6000 is expected instead,
  70. " call assert_fails("let x = matchfuzzy(l, 'cam', {'text_cb' : []})", 'E921:')
  71. call assert_fails("let x = matchfuzzy(l, 'cam', {'text_cb' : []})", 'E6000:')
  72. call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : []})", 'E730:')
  73. call assert_fails("let x = matchfuzzy(l, 'cam', v:_null_dict)", 'E1297:')
  74. call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : v:_null_string})", 'E475:')
  75. " Nvim doesn't have null functions
  76. " call assert_fails("let x = matchfuzzy(l, 'foo', {'text_cb' : test_null_function()})", 'E475:')
  77. " matches with same score should not be reordered
  78. let l = [#{text: 'abc', id: 1}, #{text: 'abc', id: 2}, #{text: 'abc', id: 3}]
  79. call assert_equal(l, l->matchfuzzy('abc', #{key: 'text'}))
  80. let l = [{'id' : 5, 'name' : 'foo'}, {'id' : 6, 'name' : []}, {'id' : 7}]
  81. call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : 'name'})", 'E730:')
  82. " Test in latin1 encoding
  83. let save_enc = &encoding
  84. " Nvim supports utf-8 encoding only
  85. " set encoding=latin1
  86. call assert_equal(['abc'], matchfuzzy(['abc'], 'abc'))
  87. let &encoding = save_enc
  88. endfunc
  89. " Test for the matchfuzzypos() function
  90. func Test_matchfuzzypos()
  91. call assert_equal([['curl', 'world'], [[2,3], [2,3]], [128, 127]], matchfuzzypos(['world', 'curl'], 'rl'))
  92. call assert_equal([['curl', 'world'], [[2,3], [2,3]], [128, 127]], matchfuzzypos(['world', 'one', 'curl'], 'rl'))
  93. call assert_equal([['hello', 'hello world hello world'],
  94. \ [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]], [275, 257]],
  95. \ matchfuzzypos(['hello world hello world', 'hello', 'world'], 'hello'))
  96. call assert_equal([['aaaaaaa'], [[0, 1, 2]], [191]], matchfuzzypos(['aaaaaaa'], 'aaa'))
  97. call assert_equal([['a b'], [[0, 3]], [219]], matchfuzzypos(['a b'], 'a b'))
  98. call assert_equal([['a b'], [[0, 3]], [219]], matchfuzzypos(['a b'], 'a b'))
  99. call assert_equal([['a b'], [[0]], [112]], matchfuzzypos(['a b'], ' a '))
  100. call assert_equal([[], [], []], matchfuzzypos(['a b'], ' '))
  101. call assert_equal([[], [], []], matchfuzzypos(['world', 'curl'], 'ab'))
  102. let x = matchfuzzypos([repeat('a', 256)], repeat('a', 256))
  103. call assert_equal(range(256), x[1][0])
  104. call assert_equal([[], [], []], matchfuzzypos([repeat('a', 300)], repeat('a', 257)))
  105. call assert_equal([[], [], []], matchfuzzypos([], 'abc'))
  106. " match in a long string
  107. call assert_equal([[repeat('x', 300) .. 'abc'], [[300, 301, 302]], [-135]],
  108. \ matchfuzzypos([repeat('x', 300) .. 'abc'], 'abc'))
  109. " preference for camel case match
  110. call assert_equal([['xabcxxaBc'], [[6, 7, 8]], [189]], matchfuzzypos(['xabcxxaBc'], 'abc'))
  111. " preference for match after a separator (_ or space)
  112. call assert_equal([['xabx_ab'], [[5, 6]], [145]], matchfuzzypos(['xabx_ab'], 'ab'))
  113. " preference for leading letter match
  114. call assert_equal([['abcxabc'], [[0, 1]], [150]], matchfuzzypos(['abcxabc'], 'ab'))
  115. " preference for sequential match
  116. call assert_equal([['aobncedone'], [[7, 8, 9]], [158]], matchfuzzypos(['aobncedone'], 'one'))
  117. " best recursive match
  118. call assert_equal([['xoone'], [[2, 3, 4]], [168]], matchfuzzypos(['xoone'], 'one'))
  119. " match multiple words (separated by space)
  120. call assert_equal([['foo bar baz'], [[8, 9, 10, 0, 1, 2]], [369]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo'))
  121. call assert_equal([[], [], []], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo', {'matchseq': 1}))
  122. call assert_equal([['foo bar baz'], [[0, 1, 2, 8, 9, 10]], [369]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz'))
  123. call assert_equal([['foo bar baz'], [[0, 1, 2, 3, 4, 5, 10]], [326]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz', {'matchseq': 1}))
  124. call assert_equal([[], [], []], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('one two'))
  125. call assert_equal([[], [], []], ['foo bar']->matchfuzzypos(" \t "))
  126. call assert_equal([['grace'], [[1, 2, 3, 4, 2, 3, 4, 0, 1, 2, 3, 4]], [657]], ['grace']->matchfuzzypos('race ace grace'))
  127. let l = [{'id' : 5, 'val' : 'crayon'}, {'id' : 6, 'val' : 'camera'}]
  128. call assert_equal([[{'id' : 6, 'val' : 'camera'}], [[0, 1, 2]], [192]],
  129. \ matchfuzzypos(l, 'cam', {'text_cb' : {v -> v.val}}))
  130. call assert_equal([[{'id' : 6, 'val' : 'camera'}], [[0, 1, 2]], [192]],
  131. \ matchfuzzypos(l, 'cam', {'key' : 'val'}))
  132. call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'text_cb' : {v -> v.val}}))
  133. call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'key' : 'val'}))
  134. call assert_fails("let x = matchfuzzypos(l, 'cam', 'random')", 'E1206:')
  135. call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'text_cb' : {v -> []}}))
  136. call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'text_cb' : {v -> 1}}))
  137. call assert_fails("let x = matchfuzzypos(l, 'day', {'text_cb' : {a, b -> 1}})", 'E119:')
  138. call assert_equal([[], [], []], matchfuzzypos(l, 'cam'))
  139. " Nvim's callback implementation is different, so E6000 is expected instead,
  140. " call assert_fails("let x = matchfuzzypos(l, 'cam', {'text_cb' : []})", 'E921:')
  141. call assert_fails("let x = matchfuzzypos(l, 'cam', {'text_cb' : []})", 'E6000:')
  142. call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : []})", 'E730:')
  143. call assert_fails("let x = matchfuzzypos(l, 'cam', v:_null_dict)", 'E1297:')
  144. call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : v:_null_string})", 'E475:')
  145. " Nvim doesn't have null functions
  146. " call assert_fails("let x = matchfuzzypos(l, 'foo', {'text_cb' : test_null_function()})", 'E475:')
  147. let l = [{'id' : 5, 'name' : 'foo'}, {'id' : 6, 'name' : []}, {'id' : 7}]
  148. call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : 'name'})", 'E730:')
  149. endfunc
  150. " Test for matchfuzzy() with multibyte characters
  151. func Test_matchfuzzy_mbyte()
  152. CheckFeature multi_lang
  153. call assert_equal(['ンヹㄇヺヴ'], matchfuzzy(['ンヹㄇヺヴ'], 'ヹヺ'))
  154. " reverse the order of characters
  155. call assert_equal([], matchfuzzy(['ンヹㄇヺヴ'], 'ヺヹ'))
  156. call assert_equal(['αβΩxxx', 'xαxβxΩx'],
  157. \ matchfuzzy(['αβΩxxx', 'xαxβxΩx'], 'αβΩ'))
  158. call assert_equal(['ππbbππ', 'πππbbbπππ', 'ππππbbbbππππ', 'πbπ'],
  159. \ matchfuzzy(['πbπ', 'ππbbππ', 'πππbbbπππ', 'ππππbbbbππππ'], 'ππ'))
  160. " match multiple words (separated by space)
  161. call assert_equal(['세 마리의 작은 돼지'], ['세 마리의 작은 돼지', '마리의', '마리의 작은', '작은 돼지']->matchfuzzy('돼지 마리의'))
  162. call assert_equal([], ['세 마리의 작은 돼지', '마리의', '마리의 작은', '작은 돼지']->matchfuzzy('파란 하늘'))
  163. " preference for camel case match
  164. call assert_equal(['oneĄwo', 'oneąwo'],
  165. \ ['oneąwo', 'oneĄwo']->matchfuzzy('oneąwo'))
  166. " preference for complete match then match after separator (_ or space)
  167. call assert_equal(['ⅠⅡabㄟㄠ'] + sort(['ⅠⅡa_bㄟㄠ', 'ⅠⅡa bㄟㄠ']),
  168. \ ['ⅠⅡabㄟㄠ', 'ⅠⅡa bㄟㄠ', 'ⅠⅡa_bㄟㄠ']->matchfuzzy('ⅠⅡabㄟㄠ'))
  169. " preference for match after a separator (_ or space)
  170. call assert_equal(['ㄓㄔabㄟㄠ', 'ㄓㄔa_bㄟㄠ', 'ㄓㄔa bㄟㄠ'],
  171. \ ['ㄓㄔa_bㄟㄠ', 'ㄓㄔa bㄟㄠ', 'ㄓㄔabㄟㄠ']->matchfuzzy('ㄓㄔabㄟㄠ'))
  172. " preference for leading letter match
  173. call assert_equal(['ŗŝţũŵż', 'xŗŝţũŵż'],
  174. \ ['xŗŝţũŵż', 'ŗŝţũŵż']->matchfuzzy('ŗŝţũŵż'))
  175. " preference for sequential match
  176. call assert_equal(['ㄞㄡㄤfffifl', 'ㄞaㄡbㄤcffdfiefl'],
  177. \ ['ㄞaㄡbㄤcffdfiefl', 'ㄞㄡㄤfffifl']->matchfuzzy('ㄞㄡㄤfffifl'))
  178. " non-matching leading letter(s) penalty
  179. call assert_equal(['xㄞㄡㄤfffifl', 'xxㄞㄡㄤfffifl'],
  180. \ ['xxㄞㄡㄤfffifl', 'xㄞㄡㄤfffifl']->matchfuzzy('ㄞㄡㄤfffifl'))
  181. " total non-matching letter(s) penalty
  182. call assert_equal(['ŗŝţ', 'ŗŝţx', 'ŗŝţxx'],
  183. \ ['ŗŝţxx', 'ŗŝţ', 'ŗŝţx']->matchfuzzy('ŗŝţ'))
  184. endfunc
  185. " Test for matchfuzzypos() with multibyte characters
  186. func Test_matchfuzzypos_mbyte()
  187. CheckFeature multi_lang
  188. call assert_equal([['こんにちは世界'], [[0, 1, 2, 3, 4]], [273]],
  189. \ matchfuzzypos(['こんにちは世界'], 'こんにちは'))
  190. call assert_equal([['ンヹㄇヺヴ'], [[1, 3]], [88]], matchfuzzypos(['ンヹㄇヺヴ'], 'ヹヺ'))
  191. " reverse the order of characters
  192. call assert_equal([[], [], []], matchfuzzypos(['ンヹㄇヺヴ'], 'ヺヹ'))
  193. call assert_equal([['αβΩxxx', 'xαxβxΩx'], [[0, 1, 2], [1, 3, 5]], [222, 113]],
  194. \ matchfuzzypos(['αβΩxxx', 'xαxβxΩx'], 'αβΩ'))
  195. call assert_equal([['ππbbππ', 'πππbbbπππ', 'ππππbbbbππππ', 'πbπ'],
  196. \ [[0, 1], [0, 1], [0, 1], [0, 2]], [151, 148, 145, 110]],
  197. \ matchfuzzypos(['πbπ', 'ππbbππ', 'πππbbbπππ', 'ππππbbbbππππ'], 'ππ'))
  198. call assert_equal([['ααααααα'], [[0, 1, 2]], [191]],
  199. \ matchfuzzypos(['ααααααα'], 'ααα'))
  200. call assert_equal([[], [], []], matchfuzzypos(['ンヹㄇ', 'ŗŝţ'], 'fffifl'))
  201. let x = matchfuzzypos([repeat('Ψ', 256)], repeat('Ψ', 256))
  202. call assert_equal(range(256), x[1][0])
  203. call assert_equal([[], [], []], matchfuzzypos([repeat('✓', 300)], repeat('✓', 257)))
  204. " match multiple words (separated by space)
  205. call assert_equal([['세 마리의 작은 돼지'], [[9, 10, 2, 3, 4]], [328]], ['세 마리의 작은 돼지', '마리의', '마리의 작은', '작은 돼지']->matchfuzzypos('돼지 마리의'))
  206. call assert_equal([[], [], []], ['세 마리의 작은 돼지', '마리의', '마리의 작은', '작은 돼지']->matchfuzzypos('파란 하늘'))
  207. " match in a long string
  208. call assert_equal([[repeat('ぶ', 300) .. 'ẼẼẼ'], [[300, 301, 302]], [-135]],
  209. \ matchfuzzypos([repeat('ぶ', 300) .. 'ẼẼẼ'], 'ẼẼẼ'))
  210. " preference for camel case match
  211. call assert_equal([['xѳѵҁxxѳѴҁ'], [[6, 7, 8]], [189]], matchfuzzypos(['xѳѵҁxxѳѴҁ'], 'ѳѵҁ'))
  212. " preference for match after a separator (_ or space)
  213. call assert_equal([['xちだx_ちだ'], [[5, 6]], [145]], matchfuzzypos(['xちだx_ちだ'], 'ちだ'))
  214. " preference for leading letter match
  215. call assert_equal([['ѳѵҁxѳѵҁ'], [[0, 1]], [150]], matchfuzzypos(['ѳѵҁxѳѵҁ'], 'ѳѵ'))
  216. " preference for sequential match
  217. call assert_equal([['aンbヹcㄇdンヹㄇ'], [[7, 8, 9]], [158]], matchfuzzypos(['aンbヹcㄇdンヹㄇ'], 'ンヹㄇ'))
  218. " best recursive match
  219. call assert_equal([['xффйд'], [[2, 3, 4]], [168]], matchfuzzypos(['xффйд'], 'фйд'))
  220. endfunc
  221. " Test for matchfuzzy() with limit
  222. func Test_matchfuzzy_limit()
  223. let x = ['1', '2', '3', '2']
  224. call assert_equal(['2', '2'], x->matchfuzzy('2'))
  225. call assert_equal(['2', '2'], x->matchfuzzy('2', #{}))
  226. call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 0}))
  227. call assert_equal(['2'], x->matchfuzzy('2', #{limit: 1}))
  228. call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 2}))
  229. call assert_equal(['2', '2'], x->matchfuzzy('2', #{limit: 3}))
  230. call assert_fails("call matchfuzzy(x, '2', #{limit: '2'})", 'E475:')
  231. let l = [{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}]
  232. call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{text_cb: {v -> v.val}}))
  233. call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{key: 'val'}))
  234. call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{text_cb: {v -> v.val}, limit: 0}))
  235. call assert_equal([{'id': 5, 'val': 'crayon'}, {'id': 6, 'val': 'camera'}], l->matchfuzzy('c', #{key: 'val', limit: 0}))
  236. call assert_equal([{'id': 5, 'val': 'crayon'}], l->matchfuzzy('c', #{text_cb: {v -> v.val}, limit: 1}))
  237. call assert_equal([{'id': 5, 'val': 'crayon'}], l->matchfuzzy('c', #{key: 'val', limit: 1}))
  238. endfunc
  239. " This was using uninitialized memory
  240. func Test_matchfuzzy_initialized()
  241. CheckRunVimInTerminal
  242. " This can take a very long time (esp. when using valgrind). Run in a
  243. " separate Vim instance and kill it after two seconds. We only check for
  244. " memory errors.
  245. let lines =<< trim END
  246. lvimgrep [ss [fg*
  247. END
  248. call writefile(lines, 'XTest_matchfuzzy', 'D')
  249. let buf = RunVimInTerminal('-u NONE -X -Z', {})
  250. call term_sendkeys(buf, ":source XTest_matchfuzzy\n")
  251. call TermWait(buf, 2000)
  252. let job = term_getjob(buf)
  253. if job_status(job) == "run"
  254. call job_stop(job, "int")
  255. call TermWait(buf, 50)
  256. endif
  257. " clean up
  258. call StopVimInTerminal(buf)
  259. endfunc
  260. " vim: shiftwidth=2 sts=2 expandtab