Skip to content

Commit 98b95da

Browse files
committed
Update vimlparser{js,py}
1 parent 3349a10 commit 98b95da

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

js/vimlparser.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -3659,15 +3659,19 @@ function StringReader() { this.__init__.apply(this, arguments); }
36593659
StringReader.prototype.__init__ = function(lines) {
36603660
this.buf = [];
36613661
this.pos = [];
3662+
this.offset = [];
36623663
var lnum = 0;
3664+
var offset = 0;
36633665
while (lnum < viml_len(lines)) {
36643666
var col = 0;
36653667
var __c7 = viml_split(lines[lnum], "\\zs");
36663668
for (var __i7 = 0; __i7 < __c7.length; ++__i7) {
36673669
var c = __c7[__i7];
36683670
viml_add(this.buf, c);
36693671
viml_add(this.pos, [lnum + 1, col + 1]);
3672+
viml_add(this.offset, offset);
36703673
col += viml_len(c);
3674+
offset += viml_len(c);
36713675
}
36723676
while (lnum + 1 < viml_len(lines) && viml_eqregh(lines[lnum + 1], "^\\s*\\\\")) {
36733677
var skip = TRUE;
@@ -3683,17 +3687,23 @@ StringReader.prototype.__init__ = function(lines) {
36833687
else {
36843688
viml_add(this.buf, c);
36853689
viml_add(this.pos, [lnum + 2, col + 1]);
3690+
viml_add(this.offset, offset);
36863691
}
36873692
col += viml_len(c);
3693+
offset += viml_len(c);
36883694
}
36893695
lnum += 1;
3696+
offset += 1;
36903697
}
36913698
viml_add(this.buf, "<EOL>");
36923699
viml_add(this.pos, [lnum + 1, col + 1]);
3700+
viml_add(this.offset, offset);
36933701
lnum += 1;
3702+
offset += 1;
36943703
}
36953704
// for <EOF>
36963705
viml_add(this.pos, [lnum + 1, 0]);
3706+
viml_add(this.offset, offset);
36973707
this.i = 0;
36983708
}
36993709

@@ -3792,7 +3802,7 @@ StringReader.prototype.getpos = function() {
37923802
var __tmp = this.pos[this.i];
37933803
var lnum = __tmp[0];
37943804
var col = __tmp[1];
3795-
return {"i":this.i, "lnum":lnum, "col":col};
3805+
return {"i":this.i, "lnum":lnum, "col":col, "offset":this.offset[this.i]};
37963806
}
37973807

37983808
StringReader.prototype.setpos = function(pos) {

py/vimlparser.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -2920,13 +2920,17 @@ class StringReader:
29202920
def __init__(self, lines):
29212921
self.buf = []
29222922
self.pos = []
2923+
self.offset = []
29232924
lnum = 0
2925+
offset = 0
29242926
while lnum < viml_len(lines):
29252927
col = 0
29262928
for c in viml_split(lines[lnum], "\\zs"):
29272929
viml_add(self.buf, c)
29282930
viml_add(self.pos, [lnum + 1, col + 1])
2931+
viml_add(self.offset, offset)
29292932
col += viml_len(c)
2933+
offset += viml_len(c)
29302934
while lnum + 1 < viml_len(lines) and viml_eqregh(lines[lnum + 1], "^\\s*\\\\"):
29312935
skip = TRUE
29322936
col = 0
@@ -2937,13 +2941,19 @@ def __init__(self, lines):
29372941
else:
29382942
viml_add(self.buf, c)
29392943
viml_add(self.pos, [lnum + 2, col + 1])
2944+
viml_add(self.offset, offset)
29402945
col += viml_len(c)
2946+
offset += viml_len(c)
29412947
lnum += 1
2948+
offset += 1
29422949
viml_add(self.buf, "<EOL>")
29432950
viml_add(self.pos, [lnum + 1, col + 1])
2951+
viml_add(self.offset, offset)
29442952
lnum += 1
2953+
offset += 1
29452954
# for <EOF>
29462955
viml_add(self.pos, [lnum + 1, 0])
2956+
viml_add(self.offset, offset)
29472957
self.i = 0
29482958

29492959
def eof(self):
@@ -3016,7 +3026,7 @@ def getstr(self, begin, end):
30163026

30173027
def getpos(self):
30183028
lnum, col = self.pos[self.i]
3019-
return AttributeDict({"i":self.i, "lnum":lnum, "col":col})
3029+
return AttributeDict({"i":self.i, "lnum":lnum, "col":col, "offset":self.offset[self.i]})
30203030

30213031
def setpos(self, pos):
30223032
self.i = pos.i

0 commit comments

Comments
 (0)