Skip to content

Commit

Permalink
Fixes #36: Do not complain if error is recoverable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jul 12, 2019
1 parent 14cb224 commit 25e4888
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
19 changes: 12 additions & 7 deletions release/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2515,9 +2515,6 @@ var Grammar = /** @class */ (function () {
}
this._injections.sort(function (i1, i2) { return i1.priority - i2.priority; }); // sort by priority
}
if (this._injections.length === 0) {
return this._injections;
}
return this._injections;
};
Grammar.prototype.registerRule = function (factory) {
Expand Down Expand Up @@ -2863,7 +2860,9 @@ function _tokenizeString(grammar, lineText, isFirstLine, linePos, stack, lineTok
anchorPosition = popped.getAnchorPos();
if (!hasAdvanced && popped.getEnterPos() === linePos) {
// Grammar pushed & popped a rule without advancing
console.error('[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing');
if (debug_1.DebugFlags.InDebugMode) {
console.error('[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing');
}
// See https://github.com/Microsoft/vscode-textmate/issues/12
// Let's assume this was a mistake by the grammar author and the intent was to continue in this state
stack = popped;
Expand Down Expand Up @@ -2897,7 +2896,9 @@ function _tokenizeString(grammar, lineText, isFirstLine, linePos, stack, lineTok
}
if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) {
// Grammar pushed the same rule without advancing
console.error('[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
if (debug_1.DebugFlags.InDebugMode) {
console.error('[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
}
stack = stack.pop();
lineTokens.produce(stack, lineLength);
STOP = true;
Expand All @@ -2920,7 +2921,9 @@ function _tokenizeString(grammar, lineText, isFirstLine, linePos, stack, lineTok
}
if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) {
// Grammar pushed the same rule without advancing
console.error('[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
if (debug_1.DebugFlags.InDebugMode) {
console.error('[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
}
stack = stack.pop();
lineTokens.produce(stack, lineLength);
STOP = true;
Expand All @@ -2938,7 +2941,9 @@ function _tokenizeString(grammar, lineText, isFirstLine, linePos, stack, lineTok
stack = stack.pop();
if (!hasAdvanced) {
// Grammar is not advancing, nor is it pushing/popping
console.error('[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping');
if (debug_1.DebugFlags.InDebugMode) {
console.error('[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping');
}
stack = stack.safePop();
lineTokens.produce(stack, lineLength);
STOP = true;
Expand Down
16 changes: 12 additions & 4 deletions src/grammar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,9 @@ function _tokenizeString(grammar: Grammar, lineText: OnigString, isFirstLine: bo

if (!hasAdvanced && popped.getEnterPos() === linePos) {
// Grammar pushed & popped a rule without advancing
console.error('[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing');
if (DebugFlags.InDebugMode) {
console.error('[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing');
}

// See https://github.com/Microsoft/vscode-textmate/issues/12
// Let's assume this was a mistake by the grammar author and the intent was to continue in this state
Expand Down Expand Up @@ -849,7 +851,9 @@ function _tokenizeString(grammar: Grammar, lineText: OnigString, isFirstLine: bo

if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) {
// Grammar pushed the same rule without advancing
console.error('[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
if (DebugFlags.InDebugMode) {
console.error('[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
}
stack = stack.pop();
lineTokens.produce(stack, lineLength);
STOP = true;
Expand All @@ -874,7 +878,9 @@ function _tokenizeString(grammar: Grammar, lineText: OnigString, isFirstLine: bo

if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) {
// Grammar pushed the same rule without advancing
console.error('[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
if (DebugFlags.InDebugMode) {
console.error('[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing');
}
stack = stack.pop();
lineTokens.produce(stack, lineLength);
STOP = true;
Expand All @@ -894,7 +900,9 @@ function _tokenizeString(grammar: Grammar, lineText: OnigString, isFirstLine: bo

if (!hasAdvanced) {
// Grammar is not advancing, nor is it pushing/popping
console.error('[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping');
if (DebugFlags.InDebugMode) {
console.error('[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping');
}
stack = stack.safePop();
lineTokens.produce(stack, lineLength);
STOP = true;
Expand Down

0 comments on commit 25e4888

Please sign in to comment.