Bram Moolenaar | 00b24be | 2016-07-23 22:04:47 +0200 | [diff] [blame] | 1 | " Test for textobjects |
| 2 | |
| 3 | if !has('textobjects') |
| 4 | finish |
| 5 | endif |
| 6 | |
| 7 | function! CpoM(line, useM, expected) |
| 8 | new |
| 9 | |
| 10 | if a:useM |
| 11 | set cpoptions+=M |
| 12 | else |
| 13 | set cpoptions-=M |
| 14 | endif |
| 15 | |
| 16 | call setline(1, a:line) |
| 17 | |
| 18 | call setreg('"', '') |
| 19 | normal! ggfrmavi)y |
| 20 | call assert_equal(getreg('"'), a:expected[0]) |
| 21 | |
| 22 | call setreg('"', '') |
| 23 | normal! `afbmavi)y |
| 24 | call assert_equal(getreg('"'), a:expected[1]) |
| 25 | |
| 26 | call setreg('"', '') |
| 27 | normal! `afgmavi)y |
| 28 | call assert_equal(getreg('"'), a:expected[2]) |
| 29 | |
| 30 | q! |
| 31 | endfunction |
| 32 | |
| 33 | function! Test_inner_block_without_cpo_M() |
| 34 | call CpoM('(red \(blue) green)', 0, ['red \(blue', 'red \(blue', '']) |
| 35 | endfunction |
| 36 | |
| 37 | function! Test_inner_block_with_cpo_M_left_backslash() |
| 38 | call CpoM('(red \(blue) green)', 1, ['red \(blue) green', 'blue', 'red \(blue) green']) |
| 39 | endfunction |
| 40 | |
| 41 | function! Test_inner_block_with_cpo_M_right_backslash() |
| 42 | call CpoM('(red (blue\) green)', 1, ['red (blue\) green', 'blue\', 'red (blue\) green']) |
| 43 | endfunction |