From 4cb1e7b849a61665db14eb0b9e43562362da5b59 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 16:16:36 +0400 Subject: [PATCH] misc fixes --- lib/ace/edit_session.js | 2 +- lib/ace/mode/c9search_highlight_rules.js | 31 ++++++++++++------------ lib/ace/mode/javascript/jshint.js | 5 +++- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index ab6f8d71..eab30e92 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -952,8 +952,8 @@ var EditSession = function(text, mode) { if (!$isPlaceholder) { this.$options.wrapMethod.set.call(this, this.$wrapMethod); this.$setFolding(mode.foldingRules); - this._emit("changeMode"); this.bgTokenizer.start(0); + this._emit("changeMode"); } }; diff --git a/lib/ace/mode/c9search_highlight_rules.js b/lib/ace/mode/c9search_highlight_rules.js index 07273bbb..ce11bf5d 100644 --- a/lib/ace/mode/c9search_highlight_rules.js +++ b/lib/ace/mode/c9search_highlight_rules.js @@ -63,23 +63,22 @@ var C9SearchHighlightRules = function() { var regex = stack[1]; var str = values[3]; - if (regex && str) - values = str.split(regex); // this doesn't work on ie8 but we don't care:) - else - values = [str]; - for (var i = 0, l = values.length; i < l; i+=2) { - if (values[i]) - tokens.push({ - type: types[2], - value: values[i] - }); - if (values[i+1]) - tokens.push({ - type: types[3], - value: values[i + 1] - }); + var m; + var last = 0; + if (regex) { + regex.lastIndex = 0; + while (m = regex.exec(str)) { + var skipped = str.substring(last, m.index); + last = regex.lastIndex; + if (skipped) + tokens.push({type: types[2], value: skipped}); + if (m[0]) + tokens.push({type: types[3], value: m[0]}); + } } + if (last < str.length) + tokens.push({type: types[2], value: str.substr(last)}); return tokens; } }, @@ -102,7 +101,7 @@ var C9SearchHighlightRules = function() { search = "\\b" + search + "\\b"; var regex = safeCreateRegexp( "(" + search + ")", - / sensitive/.test(options) ? "" : "i" + / sensitive/.test(options) ? "g" : "ig" ); if (regex) { stack[0] = state; diff --git a/lib/ace/mode/javascript/jshint.js b/lib/ace/mode/javascript/jshint.js index 1faef4ce..04f36539 100644 --- a/lib/ace/mode/javascript/jshint.js +++ b/lib/ace/mode/javascript/jshint.js @@ -7875,7 +7875,7 @@ Lexer.prototype = { this.skip(); - while (this.peek() !== quote) { + outer: while (this.peek() !== quote) { while (this.peek() === "") { // End Of Line // If an EOL is not preceded by a backslash, show a warning @@ -7927,6 +7927,9 @@ Lexer.prototype = { quote: quote }; } + + if (this.peek() == quote) + break outer; } allowNewLine = false;