blob: dca8f6320bbca4a5670c8523992384272706dd57 [file] [log] [blame]
Bram Moolenaar00b24be2016-07-23 22:04:47 +02001" Test for textobjects
2
3if !has('textobjects')
4 finish
5endif
6
Bram Moolenaarc3c766e2017-03-08 22:55:19 +01007set belloff=all
Bram Moolenaarc5e2b042017-06-05 16:37:07 +02008func CpoM(line, useM, expected)
Bram Moolenaar00b24be2016-07-23 22:04:47 +02009 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!
Bram Moolenaarc5e2b042017-06-05 16:37:07 +020032endfunc
Bram Moolenaar00b24be2016-07-23 22:04:47 +020033
Bram Moolenaarc5e2b042017-06-05 16:37:07 +020034func Test_inner_block_without_cpo_M()
Bram Moolenaar00b24be2016-07-23 22:04:47 +020035 call CpoM('(red \(blue) green)', 0, ['red \(blue', 'red \(blue', ''])
Bram Moolenaarc5e2b042017-06-05 16:37:07 +020036endfunc
Bram Moolenaar00b24be2016-07-23 22:04:47 +020037
Bram Moolenaarc5e2b042017-06-05 16:37:07 +020038func Test_inner_block_with_cpo_M_left_backslash()
Bram Moolenaar00b24be2016-07-23 22:04:47 +020039 call CpoM('(red \(blue) green)', 1, ['red \(blue) green', 'blue', 'red \(blue) green'])
Bram Moolenaarc5e2b042017-06-05 16:37:07 +020040endfunc
Bram Moolenaar00b24be2016-07-23 22:04:47 +020041
Bram Moolenaarc5e2b042017-06-05 16:37:07 +020042func Test_inner_block_with_cpo_M_right_backslash()
Bram Moolenaar00b24be2016-07-23 22:04:47 +020043 call CpoM('(red (blue\) green)', 1, ['red (blue\) green', 'blue\', 'red (blue\) green'])
Bram Moolenaarc5e2b042017-06-05 16:37:07 +020044endfunc
45
46func Test_quote_selection_selection_exclusive()
47 new
48 call setline(1, "a 'bcde' f")
49 set selection=exclusive
50 exe "norm! fdvhi'y"
51 call assert_equal('bcde', @")
52 set selection&vim
53 bw!
54endfunc