1" Test for character search commands - t, T, f, F, ; and , 2 3func Test_charsearch() 4 enew! 5 call append(0, ['Xabcdefghijkemnopqretuvwxyz', 6 \ 'Yabcdefghijkemnopqretuvwxyz', 7 \ 'Zabcdefghijkemnokqretkvwxyz']) 8 " check that "fe" and ";" work 9 1 10 normal! ylfep;;p,,p 11 call assert_equal('XabcdeXfghijkeXmnopqreXtuvwxyz', getline(1)) 12 " check that save/restore works 13 2 14 normal! ylfep 15 let csave = getcharsearch() 16 normal! fip 17 call setcharsearch(csave) 18 normal! ;p;p 19 call assert_equal('YabcdeYfghiYjkeYmnopqreYtuvwxyz', getline(2)) 20 21 " check that setcharsearch() changes the settings. 22 3 23 normal! ylfep 24 eval {'char': 'k'}->setcharsearch() 25 normal! ;p 26 call setcharsearch({'forward': 0}) 27 normal! $;p 28 call setcharsearch({'until': 1}) 29 set cpo-=; 30 normal! ;;p 31 call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3)) 32 33 " check that repeating a search before and after a line fails 34 normal 3Gfv 35 call assert_beeps('normal ;') 36 call assert_beeps('normal ,') 37 38 " clear the character search 39 call setcharsearch({'char' : ''}) 40 call assert_equal('', getcharsearch().char) 41 42 call assert_fails("call setcharsearch([])", 'E715:') 43 enew! 44endfunc 45 46" Test for character search in virtual edit mode with <Tab> 47func Test_csearch_virtualedit() 48 new 49 set virtualedit=all 50 call setline(1, "a\tb") 51 normal! tb 52 call assert_equal([0, 1, 2, 6], getpos('.')) 53 set virtualedit& 54 bw! 55endfunc 56 57" Test for character search failure in latin1 encoding 58func Test_charsearch_latin1() 59 new 60 let save_enc = &encoding 61 set encoding=latin1 62 call setline(1, 'abcdefghijk') 63 call assert_beeps('normal fz') 64 call assert_beeps('normal tx') 65 call assert_beeps('normal $Fz') 66 call assert_beeps('normal $Tx') 67 let &encoding = save_enc 68 bw! 69endfunc 70 71" Test for using character search to find a multibyte character with composing 72" characters. 73func Test_charsearch_composing_char() 74 new 75 call setline(1, "one two thq\u0328\u0301r\u0328\u0301ree") 76 call feedkeys("fr\u0328\u0301", 'xt') 77 call assert_equal([0, 1, 16, 0, 12], getcurpos()) 78 79 " use character search with a multi-byte character followed by a 80 " non-composing character 81 call setline(1, "abc deȉf ghi") 82 call feedkeys("ggcf\u0209\u0210", 'xt') 83 call assert_equal("\u0210f ghi", getline(1)) 84 bw! 85endfunc 86 87" Test for character search with 'hkmap' 88func Test_charsearch_hkmap() 89 new 90 set hkmap 91 call setline(1, "ùðáâ÷ëòéïçìêöî") 92 call feedkeys("fë", 'xt') 93 call assert_equal([0, 1, 11, 0, 6], getcurpos()) 94 set hkmap& 95 bw! 96endfunc 97 98" vim: shiftwidth=2 sts=2 expandtab 99