From 3da1f3f3ba168dae3c17f4277349be05d1c3855b Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 28 Dec 2012 20:20:37 +0400 Subject: [PATCH] do not break the editor if highlighter is malformed --- lib/ace/tokenizer.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ace/tokenizer.js b/lib/ace/tokenizer.js index 3f21c475..8d161d74 100644 --- a/lib/ace/tokenizer.js +++ b/lib/ace/tokenizer.js @@ -141,15 +141,14 @@ var Tokenizer = function(rules, flag) { if (rule.next) { currentState = rule.next; state = this.rules[currentState]; + if (!state) { + window.console && console.error && console.error(currentState, "doesn't exist"); + currentState = "start"; + state = this.rules[currentState]; + } mapping = this.matchMappings[currentState]; lastIndex = re.lastIndex; - re = this.regExps[currentState]; - - if (re === undefined) { - throw new Error("You indicated a state of " + rule.next + " to go to, but it doesn't exist!"); - } - re.lastIndex = lastIndex; } break;