@@ -86,9 +86,10 @@ type lhs struct {
8686}
8787
8888type pos struct {
89- i int
90- lnum int
91- col int
89+ i int
90+ lnum int
91+ col int
92+ offset int
9293}
9394
9495// Node returns new VimNode.
@@ -173,9 +174,10 @@ func NewLvalueParser(reader *StringReader) *LvalueParser {
173174}
174175
175176type StringReader struct {
176- i int
177- pos []pos
178- buf []string
177+ i int
178+ pos []pos
179+ buf []string
180+ offset []int
179181}
180182
181183func NewStringReader (lines []string ) * StringReader {
@@ -192,13 +194,15 @@ func (self *StringReader) __init__(lines []string) {
192194 self .buf = make ([]string , 0 , size )
193195 self .pos = make ([]pos , 0 , size + 1 ) // +1 for EOF
194196 var lnum = 0
197+ var offset = 0
195198 for lnum < len (lines ) {
196199 var col = 0
197200 for _ , r := range lines [lnum ] {
198201 c := string (r )
199202 self .buf = append (self .buf , c )
200- self .pos = append (self .pos , pos {lnum : lnum + 1 , col : col + 1 })
203+ self .pos = append (self .pos , pos {lnum : lnum + 1 , col : col + 1 , offset : offset })
201204 col += len (c )
205+ offset += len (c )
202206 }
203207 for lnum + 1 < len (lines ) && viml_eqregh (lines [lnum + 1 ], "^\\ s*\\ \\ " ) {
204208 var skip = true
@@ -214,15 +218,18 @@ func (self *StringReader) __init__(lines []string) {
214218 self .pos = append (self .pos , pos {lnum : lnum + 2 , col : col + 1 })
215219 }
216220 col += len (c )
221+ offset += len (c )
217222 }
218223 lnum += 1
224+ offset += 1
219225 }
220226 self .buf = append (self .buf , "<EOL>" )
221- self .pos = append (self .pos , pos {lnum : lnum + 1 , col : col + 1 })
227+ self .pos = append (self .pos , pos {lnum : lnum + 1 , col : col + 1 , offset : offset })
222228 lnum += 1
229+ offset += 1
223230 }
224231 // for <EOF>
225- self .pos = append (self .pos , pos {lnum : lnum + 1 , col : 0 })
232+ self .pos = append (self .pos , pos {lnum : lnum + 1 , col : 0 , offset : offset })
226233 self .i = 0
227234}
228235
0 commit comments