blob: 683bcabe34b72301d3a6b5385be9cbb004487805 [file] [log] [blame]
Bram Moolenaar1671f442020-03-10 07:48:13 +01001" Test for character search commands - t, T, f, F, ; and ,
Bram Moolenaarcd055da2016-09-02 19:50:48 +02002
Bram Moolenaar1e115362019-01-09 23:01:02 +01003func Test_charsearch()
Bram Moolenaarcd055da2016-09-02 19:50:48 +02004 enew!
5 call append(0, ['Xabcdefghijkemnopqretuvwxyz',
Bram Moolenaar53f16732016-09-07 20:46:39 +02006 \ 'Yabcdefghijkemnopqretuvwxyz',
7 \ 'Zabcdefghijkemnokqretkvwxyz'])
Bram Moolenaarcd055da2016-09-02 19:50:48 +02008 " 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
Bram Moolenaar196b4662019-09-06 21:34:30 +020024 eval {'char': 'k'}->setcharsearch()
Bram Moolenaarcd055da2016-09-02 19:50:48 +020025 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 enew!
Bram Moolenaar1e115362019-01-09 23:01:02 +010033endfunc
Bram Moolenaarcd055da2016-09-02 19:50:48 +020034
35" Test for t,f,F,T movement commands and 'cpo-;' setting
Bram Moolenaar1e115362019-01-09 23:01:02 +010036func Test_search_cmds()
Bram Moolenaarcd055da2016-09-02 19:50:48 +020037 enew!
38 call append(0, ["aaa two three four", " zzz", "yyy ",
39 \ "bbb yee yoo four", "ccc two three four",
40 \ "ddd yee yoo four"])
41 set cpo-=;
42 1
43 normal! 0tt;D
44 2
45 normal! 0fz;D
46 3
47 normal! $Fy;D
48 4
49 normal! $Ty;D
50 set cpo+=;
51 5
52 normal! 0tt;;D
53 6
54 normal! $Ty;;D
55
56 call assert_equal('aaa two', getline(1))
57 call assert_equal(' z', getline(2))
58 call assert_equal('y', getline(3))
59 call assert_equal('bbb y', getline(4))
60 call assert_equal('ccc', getline(5))
61 call assert_equal('ddd yee y', getline(6))
62 enew!
Bram Moolenaar1e115362019-01-09 23:01:02 +010063endfunc
Bram Moolenaar1671f442020-03-10 07:48:13 +010064
65" Test for character search in virtual edit mode with <Tab>
66func Test_csearch_virtualedit()
67 new
68 set virtualedit=all
69 call setline(1, "a\tb")
70 normal! tb
71 call assert_equal([0, 1, 2, 6], getpos('.'))
72 set virtualedit&
73 close!
74endfunc
75
76" vim: shiftwidth=2 sts=2 expandtab