summaryrefslogtreecommitdiff
path: root/Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js')
-rw-r--r--Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js b/Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js
index 7aafa2ad8..a51c6d0d5 100644
--- a/Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js
+++ b/Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js
@@ -1,9 +1,22 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.runMode = function(string, modespec, callback, options) {
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
- if (callback.nodeType == 1) {
+ if (callback.appendChild) {
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
var node = callback, col = 0;
node.innerHTML = "";
@@ -43,10 +56,11 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
};
}
- var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
+ var lines = CodeMirror.splitLines(string), state = (options && options.state) || CodeMirror.startState(mode);
for (var i = 0, e = lines.length; i < e; ++i) {
if (i) callback("\n");
var stream = new CodeMirror.StringStream(lines[i]);
+ if (!stream.string && mode.blankLine) mode.blankLine(state);
while (!stream.eol()) {
var style = mode.token(stream, state);
callback(stream.current(), style, i, stream.start, state);
@@ -54,3 +68,5 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
}
}
};
+
+});