Bram Moolenaar | cd055da | 2016-09-02 19:50:48 +0200 | [diff] [blame] | 1 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 2 | func Test_charsearch() |
Bram Moolenaar | cd055da | 2016-09-02 19:50:48 +0200 | [diff] [blame] | 3 | enew! |
| 4 | call append(0, ['Xabcdefghijkemnopqretuvwxyz', |
Bram Moolenaar | 53f1673 | 2016-09-07 20:46:39 +0200 | [diff] [blame] | 5 | \ 'Yabcdefghijkemnopqretuvwxyz', |
| 6 | \ 'Zabcdefghijkemnokqretkvwxyz']) |
Bram Moolenaar | cd055da | 2016-09-02 19:50:48 +0200 | [diff] [blame] | 7 | " check that "fe" and ";" work |
| 8 | 1 |
| 9 | normal! ylfep;;p,,p |
| 10 | call assert_equal('XabcdeXfghijkeXmnopqreXtuvwxyz', getline(1)) |
| 11 | " check that save/restore works |
| 12 | 2 |
| 13 | normal! ylfep |
| 14 | let csave = getcharsearch() |
| 15 | normal! fip |
| 16 | call setcharsearch(csave) |
| 17 | normal! ;p;p |
| 18 | call assert_equal('YabcdeYfghiYjkeYmnopqreYtuvwxyz', getline(2)) |
| 19 | |
| 20 | " check that setcharsearch() changes the settings. |
| 21 | 3 |
| 22 | normal! ylfep |
Bram Moolenaar | 196b466 | 2019-09-06 21:34:30 +0200 | [diff] [blame] | 23 | eval {'char': 'k'}->setcharsearch() |
Bram Moolenaar | cd055da | 2016-09-02 19:50:48 +0200 | [diff] [blame] | 24 | normal! ;p |
| 25 | call setcharsearch({'forward': 0}) |
| 26 | normal! $;p |
| 27 | call setcharsearch({'until': 1}) |
| 28 | set cpo-=; |
| 29 | normal! ;;p |
| 30 | call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3)) |
| 31 | enew! |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 32 | endfunc |
Bram Moolenaar | cd055da | 2016-09-02 19:50:48 +0200 | [diff] [blame] | 33 | |
| 34 | " Test for t,f,F,T movement commands and 'cpo-;' setting |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 35 | func Test_search_cmds() |
Bram Moolenaar | cd055da | 2016-09-02 19:50:48 +0200 | [diff] [blame] | 36 | enew! |
| 37 | call append(0, ["aaa two three four", " zzz", "yyy ", |
| 38 | \ "bbb yee yoo four", "ccc two three four", |
| 39 | \ "ddd yee yoo four"]) |
| 40 | set cpo-=; |
| 41 | 1 |
| 42 | normal! 0tt;D |
| 43 | 2 |
| 44 | normal! 0fz;D |
| 45 | 3 |
| 46 | normal! $Fy;D |
| 47 | 4 |
| 48 | normal! $Ty;D |
| 49 | set cpo+=; |
| 50 | 5 |
| 51 | normal! 0tt;;D |
| 52 | 6 |
| 53 | normal! $Ty;;D |
| 54 | |
| 55 | call assert_equal('aaa two', getline(1)) |
| 56 | call assert_equal(' z', getline(2)) |
| 57 | call assert_equal('y', getline(3)) |
| 58 | call assert_equal('bbb y', getline(4)) |
| 59 | call assert_equal('ccc', getline(5)) |
| 60 | call assert_equal('ddd yee y', getline(6)) |
| 61 | enew! |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 62 | endfunc |