|
@@ -193,7 +193,7 @@ public class TokenModel {
|
193
|
193
|
if (!remainder.isEmpty())
|
194
|
194
|
getLine(fromT.line).insert(fromT.token, new ZSToken(ZSTokenType.INVALID, remainder));
|
195
|
195
|
|
196
|
|
- relex(fromT.line, Math.max(0, fromT.token - 1), fromT.line, fromT.token + 1);
|
|
196
|
+ relex(fromT.line, Math.max(0, fromT.token - 1), fromT.line, Math.min(lines.get(fromT.line).getTokenCount(), fromT.token + 1));
|
197
|
197
|
}
|
198
|
198
|
|
199
|
199
|
public void insert(SourcePosition position, String value) {
|
|
@@ -201,7 +201,7 @@ public class TokenModel {
|
201
|
201
|
Position tokenPosition = position.asTokenPosition();
|
202
|
202
|
ZSToken token = getTokenAt(tokenPosition);
|
203
|
203
|
if (token == null) {
|
204
|
|
- line.add(new ZSToken(ZSTokenType.INVALID, value));
|
|
204
|
+ line.addTemporary(new ZSToken(ZSTokenType.INVALID, value));
|
205
|
205
|
} else {
|
206
|
206
|
token = token.insert(tokenPosition.offset, value);
|
207
|
207
|
line.replace(tokenPosition.token, token);
|
|
@@ -336,6 +336,13 @@ public class TokenModel {
|
336
|
336
|
public final int offset;
|
337
|
337
|
|
338
|
338
|
public Position(int line, int token, int offset) {
|
|
339
|
+ if (line < 0)
|
|
340
|
+ throw new IllegalArgumentException("line cannot be negative");
|
|
341
|
+ if (token < 0)
|
|
342
|
+ throw new IllegalArgumentException("token cannot be negative");
|
|
343
|
+ if (offset < 0)
|
|
344
|
+ throw new IllegalArgumentException("offset cannot be negative");
|
|
345
|
+
|
339
|
346
|
this.line = line;
|
340
|
347
|
this.token = token;
|
341
|
348
|
this.offset = offset;
|