@@ -3772,13 +3772,17 @@ endfunction
37723772function ! s: StringReader .__init__ (lines )
37733773 let self .buf = []
37743774 let self .pos = []
3775+ let self .offset = []
37753776 let lnum = 0
3777+ let offset = 0
37763778 while lnum < len (a: lines )
37773779 let col = 0
37783780 for c in split (a: lines [lnum], ' \zs' )
37793781 call add (self .buf , c )
37803782 call add (self .pos, [lnum + 1 , col + 1 ])
3783+ call add (self .offset, offset)
37813784 let col += len (c )
3785+ let offset += len (c )
37823786 endfor
37833787 while lnum + 1 < len (a: lines ) && a: lines [lnum + 1 ] = ~# ' ^\s*\\'
37843788 let skip = s: TRUE
@@ -3791,17 +3795,23 @@ function! s:StringReader.__init__(lines)
37913795 else
37923796 call add (self .buf , c )
37933797 call add (self .pos, [lnum + 2 , col + 1 ])
3798+ call add (self .offset, offset)
37943799 endif
37953800 let col += len (c )
3801+ let offset += len (c )
37963802 endfor
37973803 let lnum += 1
3804+ let offset += 1
37983805 endwhile
37993806 call add (self .buf , ' <EOL>' )
38003807 call add (self .pos, [lnum + 1 , col + 1 ])
3808+ call add (self .offset, offset)
38013809 let lnum += 1
3810+ let offset += 1
38023811 endwhile
38033812 " for <EOF>
38043813 call add (self .pos, [lnum + 1 , 0 ])
3814+ call add (self .offset, offset)
38053815 let self .i = 0
38063816endfunction
38073817
@@ -3896,7 +3906,7 @@ endfunction
38963906
38973907function ! s: StringReader .getpos ()
38983908 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 ] }
39003910endfunction
39013911
39023912function ! s: StringReader .setpos (pos)
0 commit comments