@@ -86,9 +86,10 @@ type lhs struct {
86
86
}
87
87
88
88
type pos struct {
89
- i int
90
- lnum int
91
- col int
89
+ i int
90
+ lnum int
91
+ col int
92
+ offset int
92
93
}
93
94
94
95
// Node returns new VimNode.
@@ -173,9 +174,10 @@ func NewLvalueParser(reader *StringReader) *LvalueParser {
173
174
}
174
175
175
176
type StringReader struct {
176
- i int
177
- pos []pos
178
- buf []string
177
+ i int
178
+ pos []pos
179
+ buf []string
180
+ offset []int
179
181
}
180
182
181
183
func NewStringReader (lines []string ) * StringReader {
@@ -192,13 +194,15 @@ func (self *StringReader) __init__(lines []string) {
192
194
self .buf = make ([]string , 0 , size )
193
195
self .pos = make ([]pos , 0 , size + 1 ) // +1 for EOF
194
196
var lnum = 0
197
+ var offset = 0
195
198
for lnum < len (lines ) {
196
199
var col = 0
197
200
for _ , r := range lines [lnum ] {
198
201
c := string (r )
199
202
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 })
201
204
col += len (c )
205
+ offset += len (c )
202
206
}
203
207
for lnum + 1 < len (lines ) && viml_eqregh (lines [lnum + 1 ], "^\\ s*\\ \\ " ) {
204
208
var skip = true
@@ -214,15 +218,18 @@ func (self *StringReader) __init__(lines []string) {
214
218
self .pos = append (self .pos , pos {lnum : lnum + 2 , col : col + 1 })
215
219
}
216
220
col += len (c )
221
+ offset += len (c )
217
222
}
218
223
lnum += 1
224
+ offset += 1
219
225
}
220
226
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 })
222
228
lnum += 1
229
+ offset += 1
223
230
}
224
231
// 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 })
226
233
self .i = 0
227
234
}
228
235
0 commit comments