-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathc.vim
157 lines (121 loc) · 3.41 KB
/
c.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
source t/helpers/setup.vim
describe '<Plug>(textobj-function-a)'
before
new
setfiletype c
call PasteSampleCode('c')
end
after
close!
end
it 'selects the next function if there is no function under the cursor'
Expect Select(1, 'af') ==# ['V', 3, 9]
end
it 'selects the function under the cursor'
" At the first line.
Expect Select(3, 'af') ==# ['V', 3, 9]
" At a middle line.
Expect Select(7, 'af') ==# ['V', 3, 9]
" At the last line.
Expect Select(9, 'af') ==# ['V', 3, 9]
end
it 'does not recognize a function if it is deeply indented'
Expect Select(17, 'af') ==# ['V', 23, 29]
end
it 'recognizes functinos with alternative brace style'
" With a one-line prototype
Expect Select(34, 'af') ==# ['V', 31, 36]
" With a more complex prototype
Expect Select(44, 'af') ==# ['V', 38, 46]
end
end
describe '<Plug>(textobj-function-i)'
before
new
setfiletype c
call PasteSampleCode('c')
end
after
close!
end
it 'selects the content of the next function if the cursor is not on one'
Expect Select(1, 'if') ==# ['V', 6, 8]
end
it 'selects the content of the function under the cursor'
" At the first line.
Expect Select(3, 'if') ==# ['V', 6, 8]
" At a middle line.
Expect Select(7, 'if') ==# ['V', 6, 8]
" At the last line.
Expect Select(9, 'if') ==# ['V', 6, 8]
end
it 'does not recognize a function if it is deeply indented'
Expect Select(17, 'if') ==# ['V', 26, 28]
end
it 'recognizes functinos with alternative brace style'
" With a one-line prototype
Expect Select(34, 'if') ==# ['V', 33, 35]
" With a more complex prototype
Expect Select(44, 'if') ==# ['V', 43, 45]
end
end
describe '<Plug>(textobj-function-A)'
before
new
setfiletype c
call PasteSampleCode('c')
end
after
close!
end
it 'selects the next function if there is no function under the cursor'
Expect Select(1, 'aF') ==# ['V', 2, 9]
end
it 'selects the function under the cursor'
" At the first line.
Expect Select(3, 'aF') ==# ['V', 3, 10]
" At a middle line.
Expect Select(7, 'aF') ==# ['V', 3, 10]
" At the last line.
Expect Select(9, 'aF') ==# ['V', 3, 10]
end
it 'does not recognize a function if it is deeply indented'
Expect Select(17, 'aF') ==# ['V', 22, 29]
end
it 'recognizes functinos with alternative brace style'
" With a one-line prototype
Expect Select(34, 'aF') ==# ['V', 31, 37]
" With a more complex prototype
Expect Select(44, 'aF') ==# ['V', 37, 46]
end
end
describe '<Plug>(textobj-function-I)'
before
new
setfiletype c
call PasteSampleCode('c')
end
after
close!
end
it 'selects the next function if there is no function under the cursor'
Expect Select(1, 'iF') ==# ['V', 3, 9]
end
it 'selects the function under the cursor'
" At the first line.
Expect Select(3, 'iF') ==# ['V', 3, 9]
" At a middle line.
Expect Select(7, 'iF') ==# ['V', 3, 9]
" At the last line.
Expect Select(9, 'iF') ==# ['V', 3, 9]
end
it 'does not recognize a function if it is deeply indented'
Expect Select(17, 'iF') ==# ['V', 23, 29]
end
it 'recognizes functinos with alternative brace style'
" With a one-line prototype
Expect Select(34, 'iF') ==# ['V', 31, 36]
" With a more complex prototype
Expect Select(44, 'iF') ==# ['V', 38, 46]
end
end