File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -197,3 +197,43 @@ func testParseVimLParser(t testing.TB) {
197
197
n := NewVimLParser (false ).parse (NewStringReader (lines ))
198
198
c .compile (n )
199
199
}
200
+
201
+ func TestVimLParser_offset (t * testing.T ) {
202
+ defer recovert (t )
203
+ const src = `
204
+
205
+ function! F()
206
+ let x =
207
+ \ 1
208
+
209
+ let x = "
210
+ \1
211
+ \2 <- tab
212
+ \3 マルチバイト
213
+ \4"
214
+ endfunction
215
+
216
+ " END
217
+ `
218
+ const want = `function! F()
219
+ let x =
220
+ \ 1
221
+
222
+ let x = "
223
+ \1
224
+ \2 <- tab
225
+ \3 マルチバイト
226
+ \4"
227
+ endfunction`
228
+
229
+ n := NewVimLParser (false ).parse (NewStringReader (strings .Split (src , "\n " )))
230
+ f := n .body [0 ]
231
+ start := f .pos
232
+ end := f .endfunction .pos
233
+ endfExArg := f .endfunction .ea
234
+ end .offset += endfExArg .argpos .offset - endfExArg .cmdpos .offset
235
+
236
+ if got := src [start .offset :end .offset ]; got != want {
237
+ t .Errorf ("got:\n %v\n want:\n %v" , got , want )
238
+ }
239
+ }
You can’t perform that action at this time.
0 commit comments