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