@@ -3772,13 +3772,17 @@ endfunction
3772
3772
function ! s: StringReader .__init__ (lines )
3773
3773
let self .buf = []
3774
3774
let self .pos = []
3775
+ let self .offset = []
3775
3776
let lnum = 0
3777
+ let offset = 0
3776
3778
while lnum < len (a: lines )
3777
3779
let col = 0
3778
3780
for c in split (a: lines [lnum], ' \zs' )
3779
3781
call add (self .buf , c )
3780
3782
call add (self .pos, [lnum + 1 , col + 1 ])
3783
+ call add (self .offset, offset)
3781
3784
let col += len (c )
3785
+ let offset += len (c )
3782
3786
endfor
3783
3787
while lnum + 1 < len (a: lines ) && a: lines [lnum + 1 ] = ~# ' ^\s*\\'
3784
3788
let skip = s: TRUE
@@ -3791,17 +3795,23 @@ function! s:StringReader.__init__(lines)
3791
3795
else
3792
3796
call add (self .buf , c )
3793
3797
call add (self .pos, [lnum + 2 , col + 1 ])
3798
+ call add (self .offset, offset)
3794
3799
endif
3795
3800
let col += len (c )
3801
+ let offset += len (c )
3796
3802
endfor
3797
3803
let lnum += 1
3804
+ let offset += 1
3798
3805
endwhile
3799
3806
call add (self .buf , ' <EOL>' )
3800
3807
call add (self .pos, [lnum + 1 , col + 1 ])
3808
+ call add (self .offset, offset)
3801
3809
let lnum += 1
3810
+ let offset += 1
3802
3811
endwhile
3803
3812
" for <EOF>
3804
3813
call add (self .pos, [lnum + 1 , 0 ])
3814
+ call add (self .offset, offset)
3805
3815
let self .i = 0
3806
3816
endfunction
3807
3817
@@ -3896,7 +3906,7 @@ endfunction
3896
3906
3897
3907
function ! s: StringReader .getpos ()
3898
3908
let [lnum, col ] = self .pos[self .i ]
3899
- return {' i' : self .i , ' lnum' : lnum, ' col' : col }
3909
+ return {' i' : self .i , ' lnum' : lnum, ' col' : col , ' offset ' : self .offset[ self . i ] }
3900
3910
endfunction
3901
3911
3902
3912
function ! s: StringReader .setpos (pos)
0 commit comments