From 7640bd6490ad961437a6982d7489e212777df7d8 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 12 Jul 2019 15:42:52 +0200 Subject: [PATCH] Fixes #66 --- release/main.js | 2 +- src/rule.ts | 2 +- test-cases/suite1/fixtures/66.plist | 21 ++++++++++++ test-cases/suite1/tests.json | 52 +++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 test-cases/suite1/fixtures/66.plist diff --git a/release/main.js b/release/main.js index c1fc97a..4e6b2bc 100644 --- a/release/main.js +++ b/release/main.js @@ -1959,7 +1959,7 @@ var BeginEndRule = /** @class */ (function (_super) { var _this = _super.call(this, $location, id, name, contentName) || this; _this._begin = new RegExpSource(begin, _this.id); _this.beginCaptures = beginCaptures; - _this._end = new RegExpSource(end, -1); + _this._end = new RegExpSource(end ? end : '\uFFFF', -1); _this.endHasBackReferences = _this._end.hasBackReferences; _this.endCaptures = endCaptures; _this.applyEndPatternLast = applyEndPatternLast || false; diff --git a/src/rule.ts b/src/rule.ts index 4f34d0d..84344c0 100644 --- a/src/rule.ts +++ b/src/rule.ts @@ -440,7 +440,7 @@ export class BeginEndRule extends Rule { super($location, id, name, contentName); this._begin = new RegExpSource(begin, this.id); this.beginCaptures = beginCaptures; - this._end = new RegExpSource(end, -1); + this._end = new RegExpSource(end ? end : '\uFFFF', -1); this.endHasBackReferences = this._end.hasBackReferences; this.endCaptures = endCaptures; this.applyEndPatternLast = applyEndPatternLast || false; diff --git a/test-cases/suite1/fixtures/66.plist b/test-cases/suite1/fixtures/66.plist new file mode 100644 index 0000000..0e22924 --- /dev/null +++ b/test-cases/suite1/fixtures/66.plist @@ -0,0 +1,21 @@ + + + + + scopeName + text.test + + patterns + + + begin^. + namecomment + + + + begin. + nameinvalid + + + + \ No newline at end of file diff --git a/test-cases/suite1/tests.json b/test-cases/suite1/tests.json index 80fe3a8..d527aa1 100644 --- a/test-cases/suite1/tests.json +++ b/test-cases/suite1/tests.json @@ -1422,5 +1422,57 @@ ] } ] + }, + { + "grammars": [ + "fixtures/66.plist" + ], + "grammarPath": "fixtures/66.plist", + "desc": "Issue #66", + "lines": [ + { + "line": "Just some text", + "tokens": [ + { + "value": "J", + "scopes": [ + "text.test", + "comment" + ] + }, + { + "value": "ust some text", + "scopes": [ + "text.test", + "comment" + ] + } + ] + }, + { + "line": "which contains undefined and then", + "tokens": [ + { + "value": "which contains undefined and then", + "scopes": [ + "text.test", + "comment" + ] + } + ] + }, + { + "line": "more text", + "tokens": [ + { + "value": "more text", + "scopes": [ + "text.test", + "comment" + ] + } + ] + } + ] } ] \ No newline at end of file