Core: Fixed type error on null (#3057)
This commit is contained in:
parent
8daebb4ab9
commit
a80a68ba50
|
@ -947,7 +947,7 @@ var Prism = (function (_self) {
|
||||||
|
|
||||||
if (greedy) {
|
if (greedy) {
|
||||||
match = matchPattern(pattern, pos, text, lookbehind);
|
match = matchPattern(pattern, pos, text, lookbehind);
|
||||||
if (!match) {
|
if (!match || match.index >= text.length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1000,7 +1000,7 @@ var Prism = (function (_self) {
|
||||||
|
|
||||||
if (greedy) {
|
if (greedy) {
|
||||||
match = matchPattern(pattern, pos, text, lookbehind);
|
match = matchPattern(pattern, pos, text, lookbehind);
|
||||||
if (!match) {
|
if (!match || match.index >= text.length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
prism.js
2
prism.js
|
@ -952,7 +952,7 @@ var Prism = (function (_self) {
|
||||||
|
|
||||||
if (greedy) {
|
if (greedy) {
|
||||||
match = matchPattern(pattern, pos, text, lookbehind);
|
match = matchPattern(pattern, pos, text, lookbehind);
|
||||||
if (!match) {
|
if (!match || match.index >= text.length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,4 +105,18 @@ describe('Greedy matching', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('issue3052', function () {
|
||||||
|
// If a greedy pattern creates an empty token at the end of the string, then this token should be discarded
|
||||||
|
testTokens({
|
||||||
|
grammar: {
|
||||||
|
'oh-no': {
|
||||||
|
pattern: /$/,
|
||||||
|
greedy: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
code: 'foo',
|
||||||
|
expected: ['foo']
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue