@@ -3773,12 +3773,14 @@ function! s:StringReader.__init__(lines)
3773
3773
let self .buf = []
3774
3774
let self .pos = []
3775
3775
let lnum = 0
3776
+ let offset = 0
3776
3777
while lnum < len (a: lines )
3777
3778
let col = 0
3778
3779
for c in split (a: lines [lnum], ' \zs' )
3779
3780
call add (self .buf , c )
3780
- call add (self .pos, [lnum + 1 , col + 1 ])
3781
+ call add (self .pos, [lnum + 1 , col + 1 , offset ])
3781
3782
let col += len (c )
3783
+ let offset += len (c )
3782
3784
endfor
3783
3785
while lnum + 1 < len (a: lines ) && a: lines [lnum + 1 ] = ~# ' ^\s*\\'
3784
3786
let skip = s: TRUE
@@ -3790,18 +3792,21 @@ function! s:StringReader.__init__(lines)
3790
3792
endif
3791
3793
else
3792
3794
call add (self .buf , c )
3793
- call add (self .pos, [lnum + 2 , col + 1 ])
3795
+ call add (self .pos, [lnum + 2 , col + 1 , offset ])
3794
3796
endif
3795
3797
let col += len (c )
3798
+ let offset += len (c )
3796
3799
endfor
3797
3800
let lnum += 1
3801
+ let offset += 1
3798
3802
endwhile
3799
3803
call add (self .buf , ' <EOL>' )
3800
- call add (self .pos, [lnum + 1 , col + 1 ])
3804
+ call add (self .pos, [lnum + 1 , col + 1 , offset ])
3801
3805
let lnum += 1
3806
+ let offset += 1
3802
3807
endwhile
3803
3808
" for <EOF>
3804
- call add (self .pos, [lnum + 1 , 0 ])
3809
+ call add (self .pos, [lnum + 1 , 0 , offset ])
3805
3810
let self .i = 0
3806
3811
endfunction
3807
3812
@@ -3895,8 +3900,8 @@ function! s:StringReader.getstr(begin, end)
3895
3900
endfunction
3896
3901
3897
3902
function ! s: StringReader .getpos ()
3898
- let [lnum, col ] = self .pos[self .i ]
3899
- return {' i' : self .i , ' lnum' : lnum, ' col' : col }
3903
+ let [lnum, col , offset ] = self .pos[self .i ]
3904
+ return {' i' : self .i , ' lnum' : lnum, ' col' : col , ' offset ' : offset }
3900
3905
endfunction
3901
3906
3902
3907
function ! s: StringReader .setpos (pos)
0 commit comments