Skip to content

Commit 8ec9762

Browse files
committed
context keys: scanner: fix error token eating 1 more character than needed
1 parent 542c7a5 commit 8ec9762

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/vs/platform/contextkey/common/scanner.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ export class Scanner {
290290
private _error() {
291291
const errToken = { type: TokenType.Error, offset: this._start, lexeme: this._input.substring(this._start, this._current) };
292292
this._errorTokens.push(errToken);
293-
if (!this._isAtEnd()) {
294-
++this._current;
295-
}
296293
this._tokens.push(errToken);
297294
}
298295

src/vs/platform/contextkey/test/common/scanner.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,12 @@ suite('Context Key Scanner', () => {
197197

198198
test('vim<c-r>==1 && vim<2<=3', () => {
199199
const input = 'vim<c-r>==1 && vim<2<=3';
200-
assert.deepStrictEqual(scan(input), ([{ type: "Str", lexeme: "vim<c-r>", offset: 0 }, { type: "==", offset: 8 }, { type: "Str", lexeme: "1", offset: 10 }, { type: "&&", offset: 12 }, { type: "Str", lexeme: "vim<2<", offset: 15 }, { type: "ErrorToken", offset: 21, lexeme: "=" }, { type: "EOF", offset: 23 }]));
200+
assert.deepStrictEqual(scan(input), ([{ type: "Str", offset: 0, lexeme: "vim<c-r>" }, { type: "==", offset: 8 }, { type: "Str", offset: 10, lexeme: "1" }, { type: "&&", offset: 12 }, { type: "Str", offset: 15, lexeme: "vim<2<" }, { type: "ErrorToken", offset: 21, lexeme: "=" }, { type: "Str", offset: 22, lexeme: "3" }, { type: "EOF", offset: 23 }]));
201+
});
202+
203+
test(`foo|bar`, () => {
204+
const input = `foo|bar`;
205+
assert.deepStrictEqual(scan(input), ([{ type: "Str", offset: 0, lexeme: "foo" }, { type: "ErrorToken", offset: 3, lexeme: "|" }, { type: "Str", offset: 4, lexeme: "bar" }, { type: "EOF", offset: 7 }]));
201206
});
202207
});
203208
});

0 commit comments

Comments
 (0)