Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

codemirror

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codemirror - npm Package Compare versions

Comparing version 3.14.1 to 3.15.0

addon/edit/matchtags.js

6

addon/comment/comment.js

@@ -20,3 +20,3 @@ (function() {

if (!options) options = noOptions;
var self = this, mode = CodeMirror.innerMode(self.getMode(), self.getTokenAt(from).state).mode;
var self = this, mode = self.getModeAt(from);
var commentString = options.lineComment || mode.lineComment;

@@ -56,3 +56,3 @@ if (!commentString) {

if (!options) options = noOptions;
var self = this, mode = CodeMirror.innerMode(self.getMode(), self.getTokenAt(from).state).mode;
var self = this, mode = self.getModeAt(from);
var startString = options.blockCommentStart || mode.blockCommentStart;

@@ -90,3 +90,3 @@ var endString = options.blockCommentEnd || mode.blockCommentEnd;

if (!options) options = noOptions;
var self = this, mode = CodeMirror.innerMode(self.getMode(), self.getTokenAt(from).state).mode;
var self = this, mode = self.getModeAt(from);
var end = Math.min(to.line, self.lastLine()), start = Math.min(from.line, end);

@@ -93,0 +93,0 @@

@@ -57,3 +57,5 @@ (function() {

var cur = cm.getCursor(), ahead = CodeMirror.Pos(cur.line, cur.ch + 1);
var line = cm.getLine(cur.line), nextChar = line.charAt(cur.ch);
var line = cm.getLine(cur.line), nextChar = line.charAt(cur.ch), curChar = cur.ch > 0 ? line.charAt(cur.ch - 1) : "";
if (left == right && CodeMirror.isWordChar(curChar))
return CodeMirror.Pass;
if (line.length == cur.ch || closingBrackets.indexOf(nextChar) >= 0 || SPACE_CHAR_REGEX.test(nextChar))

@@ -60,0 +62,0 @@ cm.replaceSelection(left + right, {head: ahead, anchor: ahead});

@@ -1,2 +0,2 @@

CodeMirror.braceRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "brace", function(cm, start) {
var line = start.line, lineText = cm.getLine(line);

@@ -47,5 +47,6 @@ var startCh, tokenType;

to: CodeMirror.Pos(end, endCh)};
};
});
CodeMirror.braceRangeFinder = CodeMirror.fold.brace; // deprecated
CodeMirror.importRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "import", function(cm, start) {
function hasImport(line) {

@@ -72,5 +73,6 @@ if (line < cm.firstLine() || line > cm.lastLine()) return null;

return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
};
});
CodeMirror.importRangeFinder = CodeMirror.fold["import"]; // deprecated
CodeMirror.includeRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "include", function(cm, start) {
function hasInclude(line) {

@@ -92,2 +94,3 @@ if (line < cm.firstLine() || line > cm.lastLine()) return null;

to: cm.clipPos(CodeMirror.Pos(end))};
};
});
CodeMirror.includeRangeFinder = CodeMirror.fold.include; // deprecated

@@ -5,3 +5,4 @@ (function() {

function doFold(cm, pos, options) {
var finder = options.call ? options : (options && options.rangeFinder);
var finder = options && (options.call ? options : options.rangeFinder);
if (!finder) finder = cm.getHelper(pos, "fold");
if (!finder) return;

@@ -33,3 +34,3 @@ if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);

var myWidget = makeWidget(options);
CodeMirror.on(myWidget, "mousedown", function() {myRange.clear();});
CodeMirror.on(myWidget, "mousedown", function() { myRange.clear(); });
var myRange = cm.markText(range.from, range.to, {

@@ -40,2 +41,6 @@ replacedWith: myWidget,

});
myRange.on("clear", function(from, to) {
CodeMirror.signal(cm, "unfold", cm, from, to);
});
CodeMirror.signal(cm, "fold", cm, range.from, range.to);
}

@@ -62,3 +67,3 @@

CodeMirror.combineRangeFinders = function() {
CodeMirror.registerHelper("fold", "combine", function() {
var funcs = Array.prototype.slice.call(arguments, 0);

@@ -71,3 +76,3 @@ return function(cm, start) {

};
};
});
})();

@@ -1,2 +0,2 @@

CodeMirror.indentRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);

@@ -11,2 +11,3 @@ var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);

}
};
});
CodeMirror.indentRangeFinder = CodeMirror.fold.indent; // deprecated

@@ -5,2 +5,3 @@ (function() {

var Pos = CodeMirror.Pos;
function cmp(a, b) { return a.line - b.line || a.ch - b.ch; }

@@ -11,5 +12,7 @@ var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";

function Iter(cm, line, ch) {
function Iter(cm, line, ch, range) {
this.line = line; this.ch = ch;
this.cm = cm; this.text = cm.getLine(line);
this.min = range ? range.from : cm.firstLine();
this.max = range ? range.to - 1 : cm.lastLine();
}

@@ -23,3 +26,3 @@

function nextLine(iter) {
if (iter.line >= iter.cm.lastLine()) return;
if (iter.line >= iter.max) return;
iter.ch = 0;

@@ -30,3 +33,3 @@ iter.text = iter.cm.getLine(++iter.line);

function prevLine(iter) {
if (iter.line <= iter.cm.firstLine()) return;
if (iter.line <= iter.min) return;
iter.text = iter.cm.getLine(--iter.line);

@@ -50,3 +53,3 @@ iter.ch = iter.text.length;

for (;;) {
var lt = iter.text.lastIndexOf("<", iter.ch - 1);
var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1;
if (lt == -1) { if (prevLine(iter)) continue; else return; }

@@ -73,3 +76,3 @@ if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; }

for (;;) {
var gt = iter.text.lastIndexOf(">", iter.ch - 1);
var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1;
if (gt == -1) { if (prevLine(iter)) continue; else return; }

@@ -130,3 +133,3 @@ if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; }

CodeMirror.tagRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "xml", function(cm, start) {
var iter = new Iter(cm, start.line, 0);

@@ -142,23 +145,27 @@ for (;;) {

}
};
});
CodeMirror.tagRangeFinder = CodeMirror.fold.xml; // deprecated
CodeMirror.findMatchingTag = function(cm, pos) {
var iter = new Iter(cm, pos.line, pos.ch);
var end = toTagEnd(iter), start = toTagStart(iter);
if (!end || end == "selfClose" || !start) return;
CodeMirror.findMatchingTag = function(cm, pos, range) {
var iter = new Iter(cm, pos.line, pos.ch, range);
if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch);
var start = end && toTagStart(iter);
if (!end || end == "selfClose" || !start || cmp(iter, pos) > 0) return;
var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]};
if (start[1]) { // closing tag
return findMatchingOpen(iter, start[2]);
return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"};
} else { // opening tag
toTagEnd(iter);
return findMatchingClose(iter, start[2]);
iter = new Iter(cm, to.line, to.ch, range);
return {open: here, close: findMatchingClose(iter, start[2]), at: "open"};
}
};
CodeMirror.findEnclosingTag = function(cm, pos) {
var iter = new Iter(cm, pos.line, pos.ch);
CodeMirror.findEnclosingTag = function(cm, pos, range) {
var iter = new Iter(cm, pos.line, pos.ch, range);
for (;;) {
var open = findMatchingOpen(iter);
if (!open) break;
var forward = new Iter(cm, pos.line, pos.ch);
var forward = new Iter(cm, pos.line, pos.ch, range);
var close = findMatchingClose(forward, open.tag);

@@ -165,0 +172,0 @@ if (close) return {open: open, close: close};

@@ -330,7 +330,9 @@ (function () {

CodeMirror.htmlSchema = data;
CodeMirror.htmlHint = function(cm, options) {
function htmlHint(cm, options) {
var local = {schemaInfo: data};
if (options) for (var opt in options) local[opt] = options[opt];
return CodeMirror.xmlHint(cm, local);
};
return CodeMirror.hint.xml(cm, local);
}
CodeMirror.htmlHint = htmlHint; // deprecated
CodeMirror.registerHelper("hint", "html", htmlHint);
})();

@@ -59,3 +59,3 @@ (function () {

CodeMirror.javascriptHint = function(editor, options) {
function javascriptHint(editor, options) {
return scriptHint(editor, javascriptKeywords,

@@ -65,2 +65,4 @@ function (e, cur) {return e.getTokenAt(cur);},

};
CodeMirror.javascriptHint = javascriptHint; // deprecated
CodeMirror.registerHelper("hint", "javascript", javascriptHint);

@@ -85,5 +87,7 @@ function getCoffeeScriptToken(editor, cur) {

CodeMirror.coffeescriptHint = function(editor, options) {
function coffeescriptHint(editor, options) {
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
};
}
CodeMirror.coffeescriptHint = coffeescriptHint; // deprecated
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);

@@ -90,0 +94,0 @@ var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +

@@ -44,5 +44,7 @@ (function () {

CodeMirror.pigHint = function(editor) {
function pigHint(editor) {
return scriptHint(editor, pigKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
};
}
CodeMirror.pigHint = pigHint; // deprecated
CodeMirror.registerHelper("hint", "pig", hinter);

@@ -49,0 +51,0 @@ var pigKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "

@@ -44,5 +44,7 @@ (function () {

CodeMirror.pythonHint = function(editor) {
function pythonHint(editor) {
return scriptHint(editor, pythonKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
};
}
CodeMirror.pythonHint = pythonHint; // deprecated
CodeMirror.registerHelper("hint", "python", pythonHint);

@@ -49,0 +51,0 @@ var pythonKeywords = "and del from not while as elif global or with assert else if pass yield"

@@ -7,2 +7,4 @@ (function() {

if (cm.somethingSelected()) return;
if (getHints == null) getHints = cm.getHelper(cm.getCursor(), "hint");
if (getHints == null) return;

@@ -29,6 +31,6 @@ if (cm.state.completionActive) cm.state.completionActive.close();

if (!this.active()) return;
this.cm.state.completionActive = null;
if (this.widget) this.widget.close();
if (this.onClose) this.onClose();
this.cm.state.completionActive = null;
CodeMirror.signal(this.cm, "endCompletion", this.cm);

@@ -79,2 +81,3 @@ },

if (isDone()) return;
CodeMirror.signal(data, "update");
if (completion.options.async)

@@ -85,3 +88,4 @@ completion.getHints(completion.cm, finishUpdate, completion.options);

}
function finishUpdate(data) {
function finishUpdate(data_) {
data = data_;
if (isDone()) return;

@@ -88,0 +92,0 @@ if (!data || !data.list.length) return done();

@@ -6,3 +6,3 @@ (function() {

CodeMirror.xmlHint = function(cm, options) {
function getHints(cm, options) {
var tags = options && options.schemaInfo;

@@ -65,3 +65,6 @@ var quote = (options && options.quoteChar) || '"';

};
};
}
CodeMirror.xmlHint = getHints; // deprecated
CodeMirror.registerHelper("hint", "xml", getHints);
})();
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
CodeMirror.coffeeValidator = function(text) {
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
var found = [];

@@ -24,2 +24,3 @@ var parseError = function(err) {

return found;
};
});
CodeMirror.coffeeValidator = CodeMirror.lint.coffeescript; // deprecated

@@ -12,3 +12,3 @@ (function() {

function validator(options, text) {
function validator(text, options) {
JSHINT(text, options);

@@ -20,8 +20,5 @@ var errors = JSHINT.data().errors, result = [];

CodeMirror.javascriptValidatorWithOptions = function(options) {
return function(text) { return validator(options, text); };
};
CodeMirror.registerHelper("lint", "javascript", validator);
CodeMirror.javascriptValidator = CodeMirror.lint.javascript; // deprecated
CodeMirror.javascriptValidator = CodeMirror.javascriptValidatorWithOptions(null);
function cleanup(error) {

@@ -28,0 +25,0 @@ // All problems are warnings by default

// Depends on jsonlint.js from https://github.com/zaach/jsonlint
CodeMirror.jsonValidator = function(text) {
CodeMirror.registerHelper("lint", "json", function(text) {
var found = [];

@@ -14,2 +14,3 @@ jsonlint.parseError = function(str, hash) {

return found;
};
});
CodeMirror.jsonValidator = CodeMirror.lint.json; // deprecated

@@ -1,2 +0,3 @@

CodeMirror.validate = (function() {
(function() {
"use strict";
var GUTTER_ID = "CodeMirror-lint-markers";

@@ -55,5 +56,7 @@ var SEVERITIES = /^(?:error|warning)$/;

function parseOptions(options) {
function parseOptions(cm, options) {
if (options instanceof Function) return {getAnnotations: options};
else if (!options || !options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)");
if (!options || options === true) options = {};
if (!options.getAnnotations) options.getAnnotations = cm.getHelper(CodeMirror.Pos(0, 0), "lint");
if (!options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)");
return options;

@@ -179,3 +182,3 @@ }

CodeMirror.defineOption("lintWith", false, function(cm, val, old) {
function optionHandler(cm, val, old) {
if (old && old != CodeMirror.Init) {

@@ -191,3 +194,3 @@ clearMarks(cm);

for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
var state = cm.state.lint = new LintState(cm, parseOptions(val), hasLintGutter);
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
cm.on("change", onChange);

@@ -199,3 +202,6 @@ if (state.options.tooltips != false)

}
});
}
CodeMirror.defineOption("lintWith", false, optionHandler); // deprecated
CodeMirror.defineOption("lint", false, optionHandler); // deprecated
})();

@@ -11,14 +11,14 @@ (function() {

this.classes = type == "left"
? {chunk: "CodeMirror-diff-l-chunk",
start: "CodeMirror-diff-l-chunk-start",
end: "CodeMirror-diff-l-chunk-end",
insert: "CodeMirror-diff-l-inserted",
del: "CodeMirror-diff-l-deleted",
connect: "CodeMirror-diff-l-connect"}
: {chunk: "CodeMirror-diff-r-chunk",
start: "CodeMirror-diff-r-chunk-start",
end: "CodeMirror-diff-r-chunk-end",
insert: "CodeMirror-diff-r-inserted",
del: "CodeMirror-diff-r-deleted",
connect: "CodeMirror-diff-r-connect"};
? {chunk: "CodeMirror-merge-l-chunk",
start: "CodeMirror-merge-l-chunk-start",
end: "CodeMirror-merge-l-chunk-end",
insert: "CodeMirror-merge-l-inserted",
del: "CodeMirror-merge-l-deleted",
connect: "CodeMirror-merge-l-connect"}
: {chunk: "CodeMirror-merge-r-chunk",
start: "CodeMirror-merge-r-chunk-start",
end: "CodeMirror-merge-r-chunk-end",
insert: "CodeMirror-merge-r-inserted",
del: "CodeMirror-merge-r-deleted",
connect: "CodeMirror-merge-r-connect"};
}

@@ -97,3 +97,17 @@

var ratio = (midY - off.top) / (off.bot - off.top);
other.scrollTo(null, (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top));
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
var botDist, mix;
// Some careful tweaking to make sure no space is left out of view
// when scrolling to top or bottom.
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) {
targetPos = targetPos * mix + sInfo.top * (1 - mix);
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) {
var otherInfo = other.getScrollInfo();
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos;
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1)
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix);
}
other.scrollTo(sInfo.left, targetPos);
other.state.scrollSetAt = now;

@@ -213,4 +227,4 @@ other.state.scrollSetBy = dv;

iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
if (topEdit >= vpEdit.to || botEdit < vpEdit.from ||
topOrig >= vpOrig.to || botOrig < vpOrig.from)
if (topEdit > vpEdit.to || botEdit < vpEdit.from ||
topOrig > vpOrig.to || botOrig < vpOrig.from)
return;

@@ -231,3 +245,3 @@ var topLpx = dv.orig.heightAtLine(topOrig, "local") - sTopOrig, top = topLpx;

var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
"CodeMirror-diff-copy"));
"CodeMirror-merge-copy"));
copy.title = "Revert chunk";

@@ -257,3 +271,3 @@ copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig};

left = this.left = new DiffView(this, "left");
var leftPane = elt("div", null, "CodeMirror-diff-pane");
var leftPane = elt("div", null, "CodeMirror-merge-pane");
wrap.push(leftPane);

@@ -263,3 +277,3 @@ wrap.push(buildGap(left));

var editPane = elt("div", null, "CodeMirror-diff-pane");
var editPane = elt("div", null, "CodeMirror-merge-pane");
wrap.push(editPane);

@@ -270,8 +284,10 @@

wrap.push(buildGap(right));
var rightPane = elt("div", null, "CodeMirror-diff-pane");
var rightPane = elt("div", null, "CodeMirror-merge-pane");
wrap.push(rightPane);
}
(hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost";
wrap.push(elt("div", null, null, "height: 0; clear: both;"));
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-diff CodeMirror-diff-" + panes + "pane"));
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane"));
this.edit = CodeMirror(editPane, copyObj(options));

@@ -294,7 +310,7 @@

function buildGap(dv) {
var lock = dv.lockButton = elt("div", null, "CodeMirror-diff-scrolllock");
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
lock.title = "Toggle locked scrolling";
var lockWrap = elt("div", [lock], "CodeMirror-diff-scrolllock-wrap");
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
dv.copyButtons = elt("div", null, "CodeMirror-diff-copybuttons-" + dv.type);
dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type);
CodeMirror.on(dv.copyButtons, "click", function(e) {

@@ -310,3 +326,3 @@ var node = e.target || e.srcElement;

return dv.gap = elt("div", gapElts, "CodeMirror-diff-gap");
return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap");
}

@@ -313,0 +329,0 @@

@@ -46,3 +46,4 @@ /* Just enough of CodeMirror to run runMode under node.js */

var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
var substr = this.string.substr(this.pos, pattern.length);
if (cased(substr) == cased(pattern)) {
if (consume !== false) this.pos += pattern.length;

@@ -53,2 +54,3 @@ return true;

var match = this.string.slice(this.pos).match(pattern);
if (match && match.index > 0) return null;
if (match && consume !== false) this.pos += match[0].length;

@@ -55,0 +57,0 @@ return match;

@@ -44,3 +44,4 @@ /* Just enough of CodeMirror to run runMode under node.js */

var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
var substr = this.string.substr(this.pos, pattern.length);
if (cased(substr) == cased(pattern)) {
if (consume !== false) this.pos += pattern.length;

@@ -51,2 +52,3 @@ return true;

var match = this.string.slice(this.pos).match(pattern);
if (match && match.index > 0) return null;
if (match && consume !== false) this.pos += match[0].length;

@@ -53,0 +55,0 @@ return match;

@@ -58,7 +58,9 @@ // Highlighting text that matches the selection

}
if (!cm.somethingSelected() && state.showToken) {
var tok = cm.getTokenAt(cm.getCursor()).string;
if (/\w/.test(tok))
cm.addOverlay(state.overlay = makeOverlay(tok, true, state.style));
var re = state.showToken === true ? /[\w$]/ : state.showToken;
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
while (start && re.test(line.charAt(start - 1))) --start;
while (end < line.length && re.test(line.charAt(end))) ++end;
if (start < end)
cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
return;

@@ -73,11 +75,11 @@ }

function boundariesAround(stream) {
return (stream.start || /.\b./.test(stream.string.slice(stream.start - 1, stream.start + 1))) &&
(stream.pos == stream.string.length || /.\b./.test(stream.string.slice(stream.pos - 1, stream.pos + 1)));
function boundariesAround(stream, re) {
return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) &&
(stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos)));
}
function makeOverlay(query, wordBoundaries, style) {
function makeOverlay(query, hasBoundary, style) {
return {token: function(stream) {
if (stream.match(query) &&
(!wordBoundaries || boundariesAround(stream)))
(!hasBoundary || boundariesAround(stream, hasBoundary)))
return style;

@@ -84,0 +86,0 @@ stream.next();

@@ -32,3 +32,3 @@ // Because sometimes you need to style the cursor's line.

function updateActiveLine(cm) {
var line = cm.getLineHandle(cm.getCursor().line);
var line = cm.getLineHandleVisualStart(cm.getCursor().line);
if (cm.state.activeLine == line) return;

@@ -35,0 +35,0 @@ clearActiveLine(cm);

@@ -0,30 +1,64 @@

// Glue code between CodeMirror and Tern.
//
// Create a CodeMirror.TernServer to wrap an actual Tern server,
// register open documents (CodeMirror.Doc instances) with it, and
// call its methods to activate the assisting functions that Tern
// provides.
//
// Options supported (all optional):
// * defs: An array of JSON definition data structures.
// * plugins: An object mapping plugin names to configuration
// options.
// * getFile: A function(name, c) that can be used to access files in
// the project that haven't been loaded yet. Simply do c(null) to
// indicate that a file is not available.
// * fileFilter: A function(value, docName, doc) that will be applied
// to documents before passing them on to Tern.
// * switchToDoc: A function(name) that should, when providing a
// multi-file view, switch the view or focus to the named file.
// * showError: A function(editor, message) that can be used to
// override the way errors are displayed.
// * completionTip: Customize the content in tooltips for completions.
// Is passed a single argument—the completion's data as returned by
// Tern—and may return a string, DOM node, or null to indicate that
// no tip should be shown. By default the docstring is shown.
// * typeTip: Like completionTip, but for the tooltips shown for type
// queries.
//
// It is possible to run the Tern server in a web worker by specifying
// these additional options:
// * useWorker: Set to true to enable web worker mode. You'll probably
// want to feature detect the actual value you use here, for example
// !!window.Worker.
// * workerScript: The main script of the worker. Point this to
// wherever you are hosting worker.js from this directory.
// * workerDeps: An array of paths pointing (relative to workerScript)
// to the Acorn and Tern libraries and any Tern plugins you want to
// load. Or, if you minified those into a single script and included
// them in the workerScript, simply leave this undefined.
(function() {
"use strict";
CodeMirror.getURL = function(url, c) {
var xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState != 4) return;
if (xhr.status < 400) return c(null, xhr.responseText);
var e = new Error(xhr.responseText || "No response");
e.status = xhr.status;
c(e);
};
};
CodeMirror.TernServer = function(options) {
var self = this;
this.options = options || {};
var plugins = this.options.plugins || {};
var plugins = this.options.plugins || (this.options.plugins = {});
if (!plugins.doc_comment) plugins.doc_comment = true;
this.server = new tern.Server({
getFile: function(name, c) { return getFile(self, name, c); },
async: true,
defs: this.options.defs || [],
plugins: plugins
});
if (this.options.useWorker) {
this.server = new WorkerServer(this);
} else {
this.server = new tern.Server({
getFile: function(name, c) { return getFile(self, name, c); },
async: true,
defs: this.options.defs || [],
plugins: plugins
});
}
this.docs = Object.create(null);
this.trackChange = function(doc, change) { trackChange(self, doc, change); };
this.cachedArgHints = null;
this.activeArgHints = null;
this.jumpStack = [];
};

@@ -34,5 +68,6 @@

addDoc: function(name, doc) {
this.server.addFile(name, doc.getValue());
var data = {doc: doc, name: name, changed: null};
this.server.addFile(name, docValue(this, data));
CodeMirror.on(doc, "change", this.trackChange);
return this.docs[name] = {doc: doc, name: name, changed: null};
return this.docs[name] = data;
},

@@ -43,3 +78,3 @@

if (!found) return;
CodeMirror.on(found.doc, "change", this.trackChange);
CodeMirror.off(found.doc, "change", this.trackChange);
delete this.docs[name];

@@ -49,5 +84,27 @@ this.server.delFile(name);

hideDoc: function(name) {
closeArgHints(this);
var found = this.docs[name];
if (found && found.changed) sendDoc(this, found);
},
complete: function(cm) {
var self = this;
CodeMirror.showHint(cm, function(cm, c) { return hint(self, cm, c); }, {async: true});
},
getHint: function(cm, c) { return hint(this, cm, c); },
showType: function(cm) { showType(this, cm); },
updateArgHints: function(cm) { updateArgHints(this, cm); },
jumpToDef: function(cm) { jumpToDef(this, cm); },
jumpBack: function(cm) { jumpBack(this, cm); },
rename: function(cm) { rename(this, cm); },
request: function(cm, query, c) {
this.server.request(buildRequest(this, findDoc(this, cm.getDoc()), query), c);
}

@@ -63,3 +120,3 @@ };

if (buf)
c(buf.doc.getValue());
c(docValue(ts, buf));
else if (ts.options.getFile)

@@ -71,25 +128,12 @@ ts.options.getFile(name, c);

function showError(ts, cm, string) {
if (ts.options.showError)
return ts.options.showError(cm, string);
var tip = makeTooltip(cm.cursorCoords(null, "window"), string);
function clear() {
if (!tip.parentNode) return;
cm.off("cursorActivity", clear);
remove(tip);
}
setTimeout(clear, 2000);
}
function findDoc(ts, doc, name) {
for (var name in ts.docs) {
var cur = ts.docs[name];
for (var n in ts.docs) {
var cur = ts.docs[n];
if (cur.doc == doc) return cur;
}
if (!name) for (var i = 0;; ++i) {
var n = "[doc" + (i || "") + "]";
n = "[doc" + (i || "") + "]";
if (!ts.docs[n]) { name = n; break; }
}
return ts.addDoc(n, doc);
return ts.addDoc(name, doc);
}

@@ -99,4 +143,7 @@

var data = findDoc(ts, doc);
// FIXME cache invalidation goes here
var argHints = ts.cachedArgHints;
if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) <= 0)
ts.cachedArgHints = null;
var changed = data.changed;

@@ -116,3 +163,3 @@ if (changed == null)

function sendDoc(ts, doc) {
ts.server.request({files: [{type: "full", name: doc.name, text: doc.doc.getValue()}]}, function(error) {
ts.server.request({files: [{type: "full", name: doc.name, text: docValue(ts, doc)}]}, function(error) {
if (error) console.error(error);

@@ -123,33 +170,7 @@ else doc.changed = null;

function makeTooltip(where, text) {
var node = document.createElement("div");
node.appendChild(document.createTextNode(text));
node.className = cls + "tooltip";
node.style.left = (where.right + window.pageXOffset) + "px";
node.style.top = (where.top + window.pageYOffset) + "px";
document.body.appendChild(node);
return node;
}
// Completion
function remove(node) {
var p = node && node.parentNode;
if (p) p.removeChild(node);
}
function typeToIcon(type) {
var suffix;
if (type == "?") suffix = "unknown";
else if (type == "number" || type == "string" || type == "bool") suffix = type;
else if (/^fn\(/.test(type)) suffix = "fn";
else if (/^\[/.test(type)) suffix = "array";
else suffix = "object";
return cls + "completion " + cls + "completion-" + suffix;
}
function hint(ts, cm, c) {
var doc = findDoc(ts, cm.getDoc());
var req = buildRequest(ts, doc, {type: "completions", types: true, docs: true});
ts.server.request(req, function(error, data) {
if (error) return showError(cm, error);
ts.request(cm, {type: "completions", types: true, docs: true, urls: true}, function(error, data) {
if (error) return showError(ts, cm, error);
var completions = [], after = "";

@@ -167,3 +188,3 @@ var from = data.start, to = data.end;

className: className,
doc: completion.doc});
data: completion});
}

@@ -174,8 +195,11 @@

CodeMirror.on(obj, "close", function() { remove(tooltip); });
CodeMirror.on(obj, "update", function() { remove(tooltip); });
CodeMirror.on(obj, "select", function(cur, node) {
remove(tooltip);
if (cur.doc) tooltip = makeTooltip({
top: node.getBoundingClientRect().top,
right: node.parentNode.getBoundingClientRect().right
}, cur.doc);
var content = ts.options.completionTip ? ts.options.completionTip(cur.data) : cur.data.doc;
if (content) {
tooltip = makeTooltip(node.parentNode.getBoundingClientRect().right + window.pageXOffset,
node.getBoundingClientRect().top + window.pageYOffset, content);
tooltip.className += " " + cls + "hint-doc";
}
});

@@ -186,4 +210,234 @@ c(obj);

function buildRequest(ts, doc, query, allowFragments) {
var files = [], offsetLines = 0;
function typeToIcon(type) {
var suffix;
if (type == "?") suffix = "unknown";
else if (type == "number" || type == "string" || type == "bool") suffix = type;
else if (/^fn\(/.test(type)) suffix = "fn";
else if (/^\[/.test(type)) suffix = "array";
else suffix = "object";
return cls + "completion " + cls + "completion-" + suffix;
}
// Type queries
function showType(ts, cm) {
ts.request(cm, "type", function(error, data) {
if (error) return showError(ts, cm, error);
if (ts.options.typeTip) {
var tip = ts.options.typeTip(data);
} else {
var tip = elt("span", null, elt("strong", null, data.type || "not found"));
if (data.doc)
tip.appendChild(document.createTextNode(" — " + data.doc));
if (data.url) {
tip.appendChild(document.createTextNode(" "));
tip.appendChild(elt("a", null, "[docs]")).href = data.url;
}
}
tempTooltip(cm, tip);
});
}
// Maintaining argument hints
function updateArgHints(ts, cm) {
closeArgHints(ts);
if (cm.somethingSelected()) return;
var lex = cm.getTokenAt(cm.getCursor()).state.lexical;
if (lex.info != "call") return;
var ch = lex.column, pos = lex.pos || 0;
for (var line = cm.getCursor().line, e = Math.max(0, line - 9), found = false; line >= e; --line)
if (cm.getLine(line).charAt(ch) == "(") {found = true; break;}
if (!found) return;
var start = Pos(line, ch);
var cache = ts.cachedArgHints;
if (cache && cache.doc == cm.getDoc() && cmpPos(start, cache.start) == 0)
return showArgHints(ts, cm, pos);
ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
if (error || !data.type || !(/^fn\(/).test(data.type)) return;
ts.cachedArgHints = {
start: pos,
type: parseFnType(data.type),
name: data.exprName || data.name || "fn",
guess: data.guess,
doc: cm.getDoc()
};
showArgHints(ts, cm, pos);
});
}
function showArgHints(ts, cm, pos) {
closeArgHints(ts);
var cache = ts.cachedArgHints, tp = cache.type;
var tip = elt("span", cache.guess ? cls + "fhint-guess" : null,
elt("span", cls + "fname", cache.name), "(");
for (var i = 0; i < tp.args.length; ++i) {
if (i) tip.appendChild(document.createTextNode(", "));
var arg = tp.args[i];
tip.appendChild(elt("span", cls + "farg" + (i == pos ? " " + cls + "farg-current" : ""), arg.name || "?"));
if (arg.type != "?") {
tip.appendChild(document.createTextNode(":\u00a0"));
tip.appendChild(elt("span", cls + "type", arg.type));
}
}
tip.appendChild(document.createTextNode(tp.rettype ? ") ->\u00a0" : ")"));
if (tp.rettype) tip.appendChild(elt("span", cls + "type", tp.rettype));
var place = cm.cursorCoords(null, "page");
ts.activeArgHints = makeTooltip(place.right + 1, place.bottom, tip);
}
function parseFnType(text) {
var args = [], pos = 3;
function skipMatching(upto) {
var depth = 0, start = pos;
for (;;) {
var next = text.charAt(pos);
if (upto.test(next) && !depth) return text.slice(start, pos);
if (/[{\[\(]/.test(next)) ++depth;
else if (/[}\]\)]/.test(next)) --depth;
++pos;
}
}
// Parse arguments
if (text.charAt(pos) != ")") for (;;) {
var name = text.slice(pos).match(/^([^, \(\[\{]+): /);
if (name) {
pos += name[0].length;
name = name[1];
}
args.push({name: name, type: skipMatching(/[\),]/)});
if (text.charAt(pos) == ")") break;
pos += 2;
}
var rettype = text.slice(pos).match(/^\) -> (.*)$/);
return {args: args, rettype: rettype && rettype[1]};
}
// Moving to the definition of something
function jumpToDef(ts, cm) {
function inner(varName) {
var req = {type: "definition", variable: varName || null};
var doc = findDoc(ts, cm.getDoc());
ts.server.request(buildRequest(ts, doc, req), function(error, data) {
if (error) return showError(ts, cm, error);
if (!data.file && data.url) { window.open(data.url); return; }
if (data.file) {
var localDoc = ts.docs[data.file], found;
if (localDoc && (found = findContext(localDoc.doc, data))) {
ts.jumpStack.push({file: doc.name,
start: cm.getCursor("from"),
end: cm.getCursor("to")});
moveTo(ts, doc, localDoc, found.start, found.end);
return;
}
}
showError(ts, cm, "Could not find a definition.");
});
}
if (!atInterestingExpression(cm))
dialog(cm, "Jump to variable", function(name) { if (name) inner(name); });
else
inner();
}
function jumpBack(ts, cm) {
var pos = ts.jumpStack.pop(), doc = pos && ts.docs[pos.file];
if (!doc) return;
moveTo(ts, findDoc(ts, cm.getDoc()), doc, pos.start, pos.end);
}
function moveTo(ts, curDoc, doc, start, end) {
doc.doc.setSelection(end, start);
if (curDoc != doc && ts.options.switchToDoc) {
closeArgHints(ts);
ts.options.switchToDoc(doc.name);
}
}
// The {line,ch} representation of positions makes this rather awkward.
function findContext(doc, data) {
var before = data.context.slice(0, data.contextOffset).split("\n");
var startLine = data.start.line - (before.length - 1);
var start = Pos(startLine, (before.length == 1 ? data.start.ch : doc.getLine(startLine).length) - before[0].length);
var text = doc.getLine(startLine).slice(start.ch);
for (var cur = startLine + 1; cur < doc.lineCount() && text.length < data.context.length; ++cur)
text += "\n" + doc.getLine(cur);
if (text.slice(0, data.context.length) == data.context) return data;
var cursor = doc.getSearchCursor(data.context, 0, false);
var nearest, nearestDist = Infinity;
while (cursor.findNext()) {
var from = cursor.from(), dist = Math.abs(from.line - start.line) * 10000;
if (!dist) dist = Math.abs(from.ch - start.ch);
if (dist < nearestDist) { nearest = from; nearestDist = dist; }
}
if (!nearest) return null;
if (before.length == 1)
nearest.ch += before[0].length;
else
nearest = Pos(nearest.line + (before.length - 1), before[before.length - 1].length);
if (data.start.line == data.end.line)
var end = Pos(nearest.line, nearest.ch + (data.end.ch - data.start.ch));
else
var end = Pos(nearest.line + (data.end.line - data.start.line), data.end.ch);
return {start: nearest, end: end};
}
function atInterestingExpression(cm) {
var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos);
if (tok.start < pos.ch && (tok.type == "comment" || tok.type == "string")) return false;
return /\w/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1));
}
// Variable renaming
function rename(ts, cm) {
var token = cm.getTokenAt(cm.getCursor());
if (!/\w/.test(token.string)) showError(ts, cm, "Not at a variable");
dialog(cm, "New name for " + token.string, function(newName) {
ts.request(cm, {type: "rename", newName: newName, fullDocs: true}, function(error, data) {
if (error) return showError(ts, cm, error);
applyChanges(ts, data.changes);
});
});
}
var nextChangeOrig = 0;
function applyChanges(ts, changes) {
var perFile = Object.create(null);
for (var i = 0; i < changes.length; ++i) {
var ch = changes[i];
(perFile[ch.file] || (perFile[ch.file] = [])).push(ch);
}
for (var file in perFile) {
var known = ts.docs[file], chs = perFile[file];;
if (!known) continue;
chs.sort(function(a, b) { return cmpPos(b, a); });
var origin = "*rename" + (++nextChangeOrig);
for (var i = 0; i < chs.length; ++i) {
var ch = chs[i];
known.doc.replaceRange(ch.text, ch.start, ch.end, origin);
}
}
}
// Generic request-building helper
function buildRequest(ts, doc, query) {
var files = [], offsetLines = 0, allowFragments = !query.fullDocs;
if (!allowFragments) delete query.fullDocs;
if (typeof query == "string") query = {type: query};

@@ -205,8 +459,8 @@ query.lineCharPositions = true;

var offsetLines = files[0].offsetLines;
if (query.start != null) query.start = incLine(-offsetLines, query.start);
query.end = incLine(-offsetLines, query.end);
if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch);
query.end = Pos(query.end.line - offsetLines, query.end.ch);
} else {
files.push({type: "full",
name: doc.name,
text: doc.doc.getValue()});
text: docValue(ts, doc)});
query.file = doc.name;

@@ -221,3 +475,3 @@ doc.changed = null;

if (cur.changed && cur != doc) {
files.push({type: "full", name: cur.name, text: cur.doc.getValue()});
files.push({type: "full", name: cur.name, text: docValue(ts, cur)});
cur.changed = null;

@@ -232,3 +486,3 @@ }

var doc = data.doc;
var minIndent = null, minLine = null, endLine, tabSize = doc.getOption("tabSize");
var minIndent = null, minLine = null, endLine, tabSize = 4;
for (var p = start.line - 1, min = Math.max(0, p - 50); p >= min; --p) {

@@ -257,3 +511,113 @@ var line = doc.getLine(p), fn = line.search(/\bfunction\b/);

}
window.gfa = getFragmentAround;
// Generic utilities
function cmpPos(a, b) { return a.line - b.line || a.ch - b.ch; }
function elt(tagname, cls /*, ... elts*/) {
var e = document.createElement(tagname);
if (cls) e.className = cls;
for (var i = 2; i < arguments.length; ++i) {
var elt = arguments[i];
if (typeof elt == "string") elt = document.createTextNode(elt);
e.appendChild(elt);
}
return e;
}
function dialog(cm, text, f) {
if (cm.openDialog)
cm.openDialog(text + ": <input type=text>", f);
else
f(prompt(text, ""));
}
// Tooltips
function tempTooltip(cm, content) {
var where = cm.cursorCoords();
var tip = makeTooltip(where.right + 1, where.bottom, content);
function clear() {
if (!tip.parentNode) return;
cm.off("cursorActivity", clear);
fadeOut(tip);
}
setTimeout(clear, 1700);
cm.on("cursorActivity", clear);
}
function makeTooltip(x, y, content) {
var node = elt("div", cls + "tooltip", content);
node.style.left = x + "px";
node.style.top = y + "px";
document.body.appendChild(node);
return node;
}
function remove(node) {
var p = node && node.parentNode;
if (p) p.removeChild(node);
}
function fadeOut(tooltip) {
tooltip.style.opacity = "0";
setTimeout(function() { remove(tooltip); }, 1100);
}
function showError(ts, cm, msg) {
if (ts.options.showError)
ts.options.showError(cm, msg);
else
tempTooltip(cm, String(msg));
}
function closeArgHints(ts) {
if (ts.activeArgHints) { remove(ts.activeArgHints); ts.activeArgHints = null; }
}
function docValue(ts, doc) {
var val = doc.doc.getValue();
if (ts.options.fileFilter) val = ts.options.fileFilter(val, doc.name, doc.doc);
return val;
}
// Worker wrapper
function WorkerServer(ts) {
var worker = new Worker(ts.options.workerScript);
worker.postMessage({type: "init",
defs: ts.options.defs,
plugins: ts.options.plugins,
scripts: ts.options.workerDeps});
var msgId = 0, pending = {};
function send(data, c) {
if (c) {
data.id = ++msgId;
pending[msgId] = c;
}
worker.postMessage(data);
}
worker.onmessage = function(e) {
var data = e.data;
if (data.type == "getFile") {
getFile(ts, name, function(err, text) {
send({type: "getFile", err: String(err), text: text, id: data.id});
});
} else if (data.type == "debug") {
console.log(data.message);
} else if (data.id && pending[data.id]) {
pending[data.id](data.err, data.body);
delete pending[data.id];
}
};
worker.onerror = function(e) {
for (var id in pending) pending[id](e);
pending = {};
};
this.addFile = function(name, text) { send({type: "add", name: name, text: text}); };
this.delFile = function(name) { send({type: "del", name: name}); };
this.request = function(body, c) { send({type: "req", body: body}, c); };
}
})();
{
"name": "CodeMirror",
"version": "3.13.0",
"version": "3.15.0",
"main": ["lib/codemirror.js", "lib/codemirror.css"],

@@ -5,0 +5,0 @@ "ignore": [

@@ -161,3 +161,4 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {

blockCommentEnd: "*/",
lineComment: "//"
lineComment: "//",
fold: "brace"
};

@@ -164,0 +165,0 @@ });

@@ -342,3 +342,4 @@ /**

lineComment: "#"
lineComment: "#",
fold: "indent"
};

@@ -345,0 +346,0 @@ return external;

@@ -106,3 +106,4 @@ CodeMirror.defineMode("css", function(config) {

baseIndent: base || 0,
stack: []};
stack: [],
lastToken: null};
},

@@ -167,3 +168,3 @@

if (type == "variable-definition") state.stack.push("propertyValue");
return "variable-2";
return state.lastToken = "variable-2";
} else if (style == "property") {

@@ -256,3 +257,2 @@ var word = stream.current().toLowerCase();

if (context == "@media" || context == "@mediaType") {
state.stack.pop();
state.stack[state.stack.length-1] = "@media{";

@@ -266,4 +266,3 @@ }

else if (type == "}") {
var lastState = state.stack[state.stack.length - 1];
if (lastState == "interpolation") style = "operator";
if (context == "interpolation") style = "operator";
state.stack.pop();

@@ -276,10 +275,27 @@ if (context == "propertyValue") state.stack.pop();

else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
state.stack.push("@mediaType");
else if (context == "@mediaType" && stream.current() == ",") state.stack.pop();
else if (context == "@mediaType" && type == "(") state.stack.push("@mediaType(");
else if (context == "@mediaType(" && type == ")") state.stack.pop();
else if ((context == "rule" || context == "block") && type == ":") state.stack.push("propertyValue");
state.stack[state.stack.length-1] = "@mediaType";
else if (context == "@mediaType" && stream.current() == ",")
state.stack[state.stack.length-1] = "@media";
else if (type == "(") {
if (context == "@media" || context == "@mediaType") {
// Make sure @mediaType is used to avoid error on {
state.stack[state.stack.length-1] = "@mediaType";
state.stack.push("@mediaType(");
}
}
else if (type == ")") {
if (context == "propertyValue" && state.stack[state.stack.length-2] == "@mediaType(") {
// In @mediaType( without closing ; after propertyValue
state.stack.pop();
state.stack.pop();
}
else if (context == "@mediaType(") {
state.stack.pop();
}
}
else if (type == ":" && state.lastToken == "property") state.stack.push("propertyValue");
else if (context == "propertyValue" && type == ";") state.stack.pop();
else if (context == "@import" && type == ";") state.stack.pop();
return style;
return state.lastToken = style;
},

@@ -290,3 +306,3 @@

if (/^\}/.test(textAfter))
n -= state.stack[state.stack.length-1] == "propertyValue" ? 2 : 1;
n -= state.stack[n-1] == "propertyValue" ? 2 : 1;
return state.baseIndent + n * indentUnit;

@@ -297,3 +313,4 @@ },

blockCommentStart: "/*",
blockCommentEnd: "*/"
blockCommentEnd: "*/",
fold: "brace"
};

@@ -394,4 +411,4 @@ });

"text-emphasis-position", "text-emphasis-style", "text-height",
"text-indent", "text-justify", "text-outline", "text-shadow",
"text-space-collapse", "text-transform", "text-underline-position",
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
"text-wrap", "top", "transform", "transform-origin", "transform-style",

@@ -403,3 +420,3 @@ "transition", "transition-delay", "transition-duration",

"voice-volume", "volume", "white-space", "widows", "width", "word-break",
"word-spacing", "word-wrap", "z-index",
"word-spacing", "word-wrap", "z-index", "zoom",
// SVG-specific

@@ -406,0 +423,0 @@ "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",

@@ -67,3 +67,3 @@ (function() {

MT('interpolation_in_property',
"[tag foo] { [operator #{][variable-2 $hello][operator }:][atom #000]; }");
"[tag foo] { [operator #{][variable-2 $hello][operator }:][number 2]; }");

@@ -70,0 +70,0 @@ MT('interpolation_in_selector',

@@ -18,3 +18,9 @@ (function() {

MT("atMediaPropertyOnly",
"[def @media] ([property color]) { } [tag foo] { }");
MT("atMediaCheckStackInvalidAttribute",
"[def @media] [attribute&error foobarhello] { [tag foo] { } }");
MT("atMediaCheckStackInvalidAttribute",
"[def @media] [attribute&error foobarhello] { } [tag foo] { }");

@@ -57,2 +63,6 @@

// Make sure nesting works with media queries
MT("atMediaMaxWidthNested",
"[def @media] [attribute screen] [operator and] ([property max-width][operator :] [number 25px]) { [tag foo] { } }");
MT("tagSelector",

@@ -113,4 +123,7 @@ "[tag foo] { }");

MT("tagTwoPropertiesURL",
"[tag foo] { [property background][operator :] [string-2 url]([string //example.com/foo.png]); [property padding][operator :] [number 0]; }");
MT("commentSGML",
"[comment <!--comment-->]");
})();

@@ -206,3 +206,4 @@ CodeMirror.defineMode("groovy", function(config) {

electricChars: "{}"
electricChars: "{}",
fold: "brace"
};

@@ -209,0 +210,0 @@ });

@@ -261,13 +261,13 @@ // TODO actually recognize syntax of TypeScript constructs

if (type == ";") return cont();
if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse(cx.state.indented));
if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse);
if (type == "function") return cont(functiondef);
if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
poplex, statement, poplex);
poplex, statement, poplex);
if (type == "variable") return cont(pushlex("stat"), maybelabel);
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
block, poplex, poplex);
block, poplex, poplex);
if (type == "case") return cont(expression, expect(":"));
if (type == "default") return cont(expect(":"));
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
statement, poplex, popcontext);
statement, poplex, popcontext);
return pass(pushlex("stat"), expression, expect(";"), poplex);

@@ -303,10 +303,11 @@ }

if (type == ",") return cont(expression);
return maybeoperatorNoComma(type, value, maybeoperatorComma);
return maybeoperatorNoComma(type, value, false);
}
function maybeoperatorNoComma(type, value, me) {
if (!me) me = maybeoperatorNoComma;
function maybeoperatorNoComma(type, value, noComma) {
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
var expr = noComma == false ? expression : expressionNoComma;
if (type == "operator") {
if (/\+\+|--/.test(value)) return cont(me);
if (value == "?") return cont(expression, expect(":"), expression);
return cont(expression);
if (value == "?") return cont(expression, expect(":"), expr);
return cont(expr);
}

@@ -316,3 +317,3 @@ if (type == ";") return;

if (type == ".") return cont(property, me);
if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, me);
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
}

@@ -379,10 +380,4 @@ function maybelabel(type) {

}
function maybeelse(indent) {
return function(type, value) {
if (type == "keyword b" && value == "else") {
cx.state.lexical = new JSLexical(indent, 0, "form", null, cx.state.lexical);
return cont(statement, poplex);
}
return pass();
};
function maybeelse(type, value) {
if (type == "keyword b" && value == "else") return cont(pushlex("form"), statement, poplex);
}

@@ -448,2 +443,8 @@ function forspec1(type) {

var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
// Kludge to prevent 'maybelse' from blocking lexical scope pops
for (var i = state.cc.length - 1; i >= 0; --i) {
var c = state.cc[i];
if (c == poplex) lexical = lexical.prev;
else if (c != maybeelse || /^else\b/.test(textAfter)) break;
}
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;

@@ -469,3 +470,5 @@ if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")

lineComment: jsonMode ? null : "//",
fold: "brace",
helperType: jsonMode ? "json" : "javascript",
jsonMode: jsonMode

@@ -472,0 +475,0 @@ };

@@ -106,2 +106,5 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {

}
// Reset state.trailingSpace
state.trailingSpace = 0;
state.trailingSpaceNewLine = false;
// Mark this line as blank

@@ -221,2 +224,8 @@ state.thisLineHasContent = false;

if (state.trailingSpaceNewLine) {
styles.push("trailing-space-new-line");
} else if (state.trailingSpace) {
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
}
return styles.length ? styles.join(' ') : null;

@@ -374,2 +383,10 @@ }

if (ch === ' ') {
if (stream.match(/ +$/, false)) {
state.trailingSpace++;
} else if (state.trailingSpace) {
state.trailingSpaceNewLine = true;
}
}
return getType(state);

@@ -459,3 +476,5 @@ }

listDepth: 0,
quote: 0
quote: 0,
trailingSpace: 0,
trailingSpaceNewLine: false
};

@@ -488,2 +507,4 @@ },

quote: s.quote,
trailingSpace: s.trailingSpace,
trailingSpaceNewLine: s.trailingSpaceNewLine,
md_inside: s.md_inside

@@ -512,2 +533,6 @@ };

// Reset state.trailingSpace
state.trailingSpace = 0;
state.trailingSpaceNewLine = false;
state.f = state.block;

@@ -514,0 +539,0 @@ var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;

@@ -8,2 +8,16 @@ (function() {

// Don't style single trailing space
MT("trailingSpace1",
"foo ");
// Two or more trailing spaces should be styled with line break character
MT("trailingSpace2",
"foo[trailing-space-a ][trailing-space-new-line ]");
MT("trailingSpace3",
"foo[trailing-space-a ][trailing-space-b ][trailing-space-new-line ]");
MT("trailingSpace4",
"foo[trailing-space-a ][trailing-space-b ][trailing-space-a ][trailing-space-new-line ]");
// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)

@@ -10,0 +24,0 @@ MT("codeBlocksUsing4Spaces",

@@ -19,3 +19,3 @@ CodeMirror.modeInfo = [

{name: 'Gas', mime: 'text/x-gas', mode: 'gas'},
{name: 'GitHub Flavored Markdown', mode: 'gfm'},
{name: 'GitHub Flavored Markdown', mime: 'text/x-gfm', mode: 'gfm'},
{name: 'GO', mime: 'text/x-go', mode: 'go'},

@@ -30,2 +30,3 @@ {name: 'Groovy', mime: 'text/x-groovy', mode: 'groovy'},

{name: 'HTTP', mime: 'message/http', mode: 'http'},
{name: 'Jade', mime: 'text/x-jade', mode: 'jade'},
{name: 'JavaScript', mime: 'text/javascript', mode: 'javascript'},

@@ -41,2 +42,3 @@ {name: 'JSON', mime: 'application/x-json', mode: 'javascript'},

{name: 'mIRC', mime: 'text/mirc', mode: 'mirc'},
{name: 'Nginx', mime: 'text/x-nginx-conf', mode: 'nginx'},
{name: 'NTriples', mime: 'text/n-triples', mode: 'ntriples'},

@@ -52,2 +54,3 @@ {name: 'OCaml', mime: 'text/x-ocaml', mode: 'ocaml'},

{name: 'Python', mime: 'text/x-python', mode: 'python'},
{name: 'Cython', mime: 'text/x-cython', mode: 'python'},
{name: 'R', mime: 'text/x-rsrc', mode: 'r'},

@@ -64,2 +67,3 @@ {name: 'reStructuredText', mime: 'text/x-rst', mode: 'rst'},

{name: 'Smarty', mime: 'text/x-smarty', mode: 'smarty'},
{name: 'SmartyMixed', mime: 'text/x-smarty', mode: 'smartymixed'},
{name: 'SPARQL', mime: 'application/x-sparql-query', mode: 'sparql'},

@@ -66,0 +70,0 @@ {name: 'SQL', mime: 'text/x-sql', mode: 'sql'},

@@ -39,2 +39,8 @@ CodeMirror.defineMode("python", function(conf, parserConf) {

if(parserConf.extra_keywords != undefined){
commonkeywords = commonkeywords.concat(parserConf.extra_keywords);
}
if(parserConf.extra_builtins != undefined){
commonBuiltins = commonBuiltins.concat(parserConf.extra_builtins);
}
if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {

@@ -322,3 +328,3 @@ commonkeywords = commonkeywords.concat(py3.keywords);

if (stream.eol() && stream.lambda) {
if (stream.eol() && state.lambda) {
state.lambda = false;

@@ -338,3 +344,4 @@ }

lineComment: "#"
lineComment: "#",
fold: "indent"
};

@@ -345,1 +352,11 @@ return external;

CodeMirror.defineMIME("text/x-python", "python");
var words = function(str){return str.split(' ');};
CodeMirror.defineMIME("text/x-cython", {
name: "python",
extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+
"extern gil include nogil property public"+
"readonly struct union DEF IF ELIF ELSE")
});
The MIT License
Copyright (c) 2013 Hasan Karahan
Copyright (c) 2013 Hasan Karahan <hasan.karahan81@gmail.com>

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -39,5 +39,7 @@ CodeMirror.defineMode('rst-base', function (config) {

var NAME = "(?:[^\\W\\d_](?:[\\w\\+\\.\\-:]*[^\\W_])?)",
var NAME =
"(?:[^\\W\\d_](?:[\\w!\"#$%&'()\\*\\+,\\-\\.\/:;<=>\\?]*[^\\W_])?)",
rx_NAME = new RegExp(format('^{0}', NAME));
var NAME_WWS = "(?:[^\\W\\d_](?:[\\w\\s\\+\\.\\-:]*[^\\W_])?)";
var NAME_WWS =
"(?:[^\\W\\d_](?:[\\w\\s!\"#$%&'()\\*\\+,\\-\\.\/:;<=>\\?]*[^\\W_])?)";
var REF_NAME = format('(?:{0}|`{1}`)', NAME, NAME_WWS);

@@ -484,3 +486,5 @@

innerMode: function (state) {
return {state: state.ctx.local, mode: state.ctx.mode};
return state.tmp ? {state: state.tmp.local, mode: state.tmp.mode}
: state.ctx ? {state: state.ctx.local, mode: state.ctx.mode}
: null;
},

@@ -499,2 +503,10 @@

var rx_strong = /^\*\*[^\*\s](?:[^\*]*[^\*\s])?\*\*/;
var rx_emphasis = /^\*[^\*\s](?:[^\*]*[^\*\s])?\*/;
var rx_literal = /^``[^`\s](?:[^`]*[^`\s])``/;
var rx_number = /^(?:[\d]+(?:[\.,]\d+)*)/;
var rx_positive = /^(?:\s\+[\d]+(?:[\.,]\d+)*)/;
var rx_negative = /^(?:\s\-[\d]+(?:[\.,]\d+)*)/;
var rx_uri_protocol = "[Hh][Tt][Tt][Pp][Ss]?://";

@@ -507,23 +519,21 @@ var rx_uri_domain = "(?:[\\d\\w.-]+)\\.(?:\\w{2,6})";

var rx_strong = /^\*\*[^\*\s](?:[^\*]*[^\*\s])?\*\*(\s+|$)/;
var rx_emphasis = /^[^\*]\*[^\*\s](?:[^\*]*[^\*\s])?\*(\s+|$)/;
var rx_literal = /^``[^`\s](?:[^`]*[^`\s])``(\s+|$)/;
var rx_number = /^(?:[\d]+(?:[\.,]\d+)*)/;
var rx_positive = /^(?:\s\+[\d]+(?:[\.,]\d+)*)/;
var rx_negative = /^(?:\s\-[\d]+(?:[\.,]\d+)*)/;
var overlay = {
token: function (stream) {
if (stream.match(rx_uri)) return 'link';
if (stream.match(rx_strong)) return 'strong';
if (stream.match(rx_emphasis)) return 'em';
if (stream.match(rx_literal)) return 'string-2';
if (stream.match(rx_number)) return 'number';
if (stream.match(rx_positive)) return 'positive';
if (stream.match(rx_negative)) return 'negative';
if (stream.match(rx_strong) && stream.match (/\W+|$/, false))
return 'strong';
if (stream.match(rx_emphasis) && stream.match (/\W+|$/, false))
return 'em';
if (stream.match(rx_literal) && stream.match (/\W+|$/, false))
return 'string-2';
if (stream.match(rx_number))
return 'number';
if (stream.match(rx_positive))
return 'positive';
if (stream.match(rx_negative))
return 'negative';
if (stream.match(rx_uri))
return 'link';
while (stream.next() != null) {
if (stream.match(rx_uri, false)) break;
if (stream.match(rx_strong, false)) break;

@@ -535,2 +545,3 @@ if (stream.match(rx_emphasis, false)) break;

if (stream.match(rx_negative, false)) break;
if (stream.match(rx_uri, false)) break;
}

@@ -537,0 +548,0 @@

@@ -39,7 +39,7 @@ CodeMirror.defineMode("ruby", function(config) {

} else if (ch == "%") {
var style = "string", embed = false;
var style = "string", embed = true;
if (stream.eat("s")) style = "atom";
else if (stream.eat(/[WQ]/)) { style = "string"; embed = true; }
else if (stream.eat(/[r]/)) { style = "string-2"; embed = true; }
else if (stream.eat(/[wxq]/)) style = "string";
else if (stream.eat(/[WQ]/)) style = "string";
else if (stream.eat(/[r]/)) style = "string-2";
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
var delim = stream.eat(/[^\w\s]/);

@@ -46,0 +46,0 @@ if (!delim) return "operator";

@@ -431,3 +431,4 @@ CodeMirror.defineMode("rust", function() {

blockCommentEnd: "*/",
lineComment: "//"
lineComment: "//",
fold: "brace"
};

@@ -434,0 +435,0 @@ });

@@ -39,4 +39,9 @@ CodeMirror.defineMode('smalltalk', function(config) {

} else if (aChar === '#') {
stream.eatWhile(/[^ .\[\]()]/);
token.name = 'string-2';
if (stream.peek() === '\'') {
stream.next();
token = nextSymbol(stream, new Context(nextSymbol, context));
} else {
stream.eatWhile(/[^ .\[\]()]/);
token.name = 'string-2';
}

@@ -93,2 +98,7 @@ } else if (aChar === '$') {

var nextSymbol = function(stream, context) {
stream.eatWhile(/[^']/);
return new Token('string-2', stream.eat('\'') ? context.parent : context, false);
};
var nextTemporaries = function(stream, context) {

@@ -95,0 +105,0 @@ var token = new Token(null, context, false);

@@ -9,6 +9,8 @@ CodeMirror.defineMode("sparql", function(config) {

var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
"isblank", "isliteral", "union", "a"]);
"isblank", "isliteral", "a"]);
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
"graph", "by", "asc", "desc"]);
"graph", "by", "asc", "desc", "as", "having", "undef", "values", "group",
"minus", "in", "not", "service", "silent", "using", "insert", "delete", "union",
"data", "copy", "to", "move", "add", "create", "drop", "clear", "load"]);
var operatorChars = /[*+\-<>=&|]/;

@@ -15,0 +17,0 @@

@@ -1,26 +0,334 @@

CodeMirror.defineMode("vbscript", function() {
var regexVBScriptKeyword = /^(?:Call|Case|CDate|Clear|CInt|CLng|Const|CStr|Description|Dim|Do|Each|Else|ElseIf|End|Err|Error|Exit|False|For|Function|If|LCase|Loop|LTrim|Next|Nothing|Now|Number|On|Preserve|Quit|ReDim|Resume|RTrim|Select|Set|Sub|Then|To|Trim|True|UBound|UCase|Until|VbCr|VbCrLf|VbLf|VbTab)$/im;
/*
For extra ASP classic objects, initialize CodeMirror instance with this option:
isASP: true
return {
token: function(stream) {
if (stream.eatSpace()) return null;
var ch = stream.next();
if (ch == "'") {
stream.skipToEnd();
return "comment";
}
if (ch == '"') {
stream.skipTo('"');
return "string";
}
E.G.:
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
isASP: true
});
*/
CodeMirror.defineMode("vbscript", function(conf, parserConf) {
var ERRORCLASS = 'error';
if (/\w/.test(ch)) {
stream.eatWhile(/\w/);
if (regexVBScriptKeyword.test(stream.current())) return "keyword";
}
return null;
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
}
};
var singleOperators = new RegExp("^[\\+\\-\\*/&\\\\\\^<>=]");
var doubleOperators = new RegExp("^((<>)|(<=)|(>=))");
var singleDelimiters = new RegExp('^[\\.,]');
var brakets = new RegExp('^[\\(\\)]');
var identifiers = new RegExp("^[A-Za-z][_A-Za-z0-9]*");
var openingKeywords = ['class','sub','select','while','if','function', 'property', 'with', 'for'];
var middleKeywords = ['else','elseif','case'];
var endKeywords = ['next','loop','wend'];
var wordOperators = wordRegexp(['and', 'or', 'not', 'xor', 'is', 'mod', 'eqv', 'imp']);
var commonkeywords = ['dim', 'redim', 'then', 'until', 'randomize',
'byval','byref','new','property', 'exit', 'in',
'const','private', 'public',
'get','set','let', 'stop', 'on error resume next', 'on error goto 0', 'option explicit', 'call', 'me'];
//This list was from: http://msdn.microsoft.com/en-us/library/f8tbc79x(v=vs.84).aspx
var atomWords = ['true', 'false', 'nothing', 'empty', 'null'];
//This list was from: http://msdn.microsoft.com/en-us/library/3ca8tfek(v=vs.84).aspx
var builtinFuncsWords = ['abs', 'array', 'asc', 'atn', 'cbool', 'cbyte', 'ccur', 'cdate', 'cdbl', 'chr', 'cint', 'clng', 'cos', 'csng', 'cstr', 'date', 'dateadd', 'datediff', 'datepart',
'dateserial', 'datevalue', 'day', 'escape', 'eval', 'execute', 'exp', 'filter', 'formatcurrency', 'formatdatetime', 'formatnumber', 'formatpercent', 'getlocale', 'getobject',
'getref', 'hex', 'hour', 'inputbox', 'instr', 'instrrev', 'int', 'fix', 'isarray', 'isdate', 'isempty', 'isnull', 'isnumeric', 'isobject', 'join', 'lbound', 'lcase', 'left',
'len', 'loadpicture', 'log', 'ltrim', 'rtrim', 'trim', 'maths', 'mid', 'minute', 'month', 'monthname', 'msgbox', 'now', 'oct', 'replace', 'rgb', 'right', 'rnd', 'round',
'scriptengine', 'scriptenginebuildversion', 'scriptenginemajorversion', 'scriptengineminorversion', 'second', 'setlocale', 'sgn', 'sin', 'space', 'split', 'sqr', 'strcomp',
'string', 'strreverse', 'tan', 'time', 'timer', 'timeserial', 'timevalue', 'typename', 'ubound', 'ucase', 'unescape', 'vartype', 'weekday', 'weekdayname', 'year'];
//This list was from: http://msdn.microsoft.com/en-us/library/ydz4cfk3(v=vs.84).aspx
var builtinConsts = ['vbBlack', 'vbRed', 'vbGreen', 'vbYellow', 'vbBlue', 'vbMagenta', 'vbCyan', 'vbWhite', 'vbBinaryCompare', 'vbTextCompare',
'vbSunday', 'vbMonday', 'vbTuesday', 'vbWednesday', 'vbThursday', 'vbFriday', 'vbSaturday', 'vbUseSystemDayOfWeek', 'vbFirstJan1', 'vbFirstFourDays', 'vbFirstFullWeek',
'vbGeneralDate', 'vbLongDate', 'vbShortDate', 'vbLongTime', 'vbShortTime', 'vbObjectError',
'vbOKOnly', 'vbOKCancel', 'vbAbortRetryIgnore', 'vbYesNoCancel', 'vbYesNo', 'vbRetryCancel', 'vbCritical', 'vbQuestion', 'vbExclamation', 'vbInformation', 'vbDefaultButton1', 'vbDefaultButton2',
'vbDefaultButton3', 'vbDefaultButton4', 'vbApplicationModal', 'vbSystemModal', 'vbOK', 'vbCancel', 'vbAbort', 'vbRetry', 'vbIgnore', 'vbYes', 'vbNo',
'vbCr', 'VbCrLf', 'vbFormFeed', 'vbLf', 'vbNewLine', 'vbNullChar', 'vbNullString', 'vbTab', 'vbVerticalTab', 'vbUseDefault', 'vbTrue', 'vbFalse',
'vbEmpty', 'vbNull', 'vbInteger', 'vbLong', 'vbSingle', 'vbDouble', 'vbCurrency', 'vbDate', 'vbString', 'vbObject', 'vbError', 'vbBoolean', 'vbVariant', 'vbDataObject', 'vbDecimal', 'vbByte', 'vbArray'];
//This list was from: http://msdn.microsoft.com/en-us/library/hkc375ea(v=vs.84).aspx
var builtinObjsWords = ['WScript', 'err', 'debug', 'RegExp'];
var knownProperties = ['description', 'firstindex', 'global', 'helpcontext', 'helpfile', 'ignorecase', 'length', 'number', 'pattern', 'source', 'value', 'count'];
var knownMethods = ['clear', 'execute', 'raise', 'replace', 'test', 'write', 'writeline', 'close', 'open', 'state', 'eof', 'update', 'addnew', 'end', 'createobject', 'quit'];
var aspBuiltinObjsWords = ['server', 'response', 'request', 'session', 'application'];
var aspKnownProperties = ['buffer', 'cachecontrol', 'charset', 'contenttype', 'expires', 'expiresabsolute', 'isclientconnected', 'pics', 'status', //response
'clientcertificate', 'cookies', 'form', 'querystring', 'servervariables', 'totalbytes', //request
'contents', 'staticobjects', //application
'codepage', 'lcid', 'sessionid', 'timeout', //session
'scripttimeout']; //server
var aspKnownMethods = ['addheader', 'appendtolog', 'binarywrite', 'end', 'flush', 'redirect', //response
'binaryread', //request
'remove', 'removeall', 'lock', 'unlock', //application
'abandon', //session
'getlasterror', 'htmlencode', 'mappath', 'transfer', 'urlencode']; //server
var knownWords = knownMethods.concat(knownProperties);
builtinObjsWords = builtinObjsWords.concat(builtinConsts);
if (conf.isASP){
builtinObjsWords = builtinObjsWords.concat(aspBuiltinObjsWords);
knownWords = knownWords.concat(aspKnownMethods, aspKnownProperties);
};
var keywords = wordRegexp(commonkeywords);
var atoms = wordRegexp(atomWords);
var builtinFuncs = wordRegexp(builtinFuncsWords);
var builtinObjs = wordRegexp(builtinObjsWords);
var known = wordRegexp(knownWords);
var stringPrefixes = '"';
var opening = wordRegexp(openingKeywords);
var middle = wordRegexp(middleKeywords);
var closing = wordRegexp(endKeywords);
var doubleClosing = wordRegexp(['end']);
var doOpening = wordRegexp(['do']);
var noIndentWords = wordRegexp(['on error resume next', 'exit']);
var comment = wordRegexp(['rem']);
function indent(_stream, state) {
state.currentIndent++;
}
function dedent(_stream, state) {
state.currentIndent--;
}
// tokenizers
function tokenBase(stream, state) {
if (stream.eatSpace()) {
return 'space';
//return null;
}
var ch = stream.peek();
// Handle Comments
if (ch === "'") {
stream.skipToEnd();
return 'comment';
}
if (stream.match(comment)){
stream.skipToEnd();
return 'comment';
}
// Handle Number Literals
if (stream.match(/^((&H)|(&O))?[0-9\.]/i, false) && !stream.match(/^((&H)|(&O))?[0-9\.]+[a-z_]/i, false)) {
var floatLiteral = false;
// Floats
if (stream.match(/^\d*\.\d+/i)) { floatLiteral = true; }
else if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
else if (stream.match(/^\.\d+/)) { floatLiteral = true; }
if (floatLiteral) {
// Float literals may be "imaginary"
stream.eat(/J/i);
return 'number';
}
// Integers
var intLiteral = false;
// Hex
if (stream.match(/^&H[0-9a-f]+/i)) { intLiteral = true; }
// Octal
else if (stream.match(/^&O[0-7]+/i)) { intLiteral = true; }
// Decimal
else if (stream.match(/^[1-9]\d*F?/)) {
// Decimal literals may be "imaginary"
stream.eat(/J/i);
// TODO - Can you have imaginary longs?
intLiteral = true;
}
// Zero by itself with no other piece of number.
else if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
if (intLiteral) {
// Integer literals may be "long"
stream.eat(/L/i);
return 'number';
}
}
// Handle Strings
if (stream.match(stringPrefixes)) {
state.tokenize = tokenStringFactory(stream.current());
return state.tokenize(stream, state);
}
// Handle operators and Delimiters
if (stream.match(doubleOperators)
|| stream.match(singleOperators)
|| stream.match(wordOperators)) {
return 'operator';
}
if (stream.match(singleDelimiters)) {
return null;
}
if (stream.match(brakets)) {
return "bracket";
}
if (stream.match(noIndentWords)) {
state.doInCurrentLine = true;
return 'keyword';
}
if (stream.match(doOpening)) {
indent(stream,state);
state.doInCurrentLine = true;
return 'keyword';
}
if (stream.match(opening)) {
if (! state.doInCurrentLine)
indent(stream,state);
else
state.doInCurrentLine = false;
return 'keyword';
}
if (stream.match(middle)) {
return 'keyword';
}
if (stream.match(doubleClosing)) {
dedent(stream,state);
dedent(stream,state);
return 'keyword';
}
if (stream.match(closing)) {
if (! state.doInCurrentLine)
dedent(stream,state);
else
state.doInCurrentLine = false;
return 'keyword';
}
if (stream.match(keywords)) {
return 'keyword';
}
if (stream.match(atoms)) {
return 'atom';
}
if (stream.match(known)) {
return 'variable-2';
}
if (stream.match(builtinFuncs)) {
return 'builtin';
}
if (stream.match(builtinObjs)){
return 'variable-2';
}
if (stream.match(identifiers)) {
return 'variable';
}
// Handle non-detected items
stream.next();
return ERRORCLASS;
}
function tokenStringFactory(delimiter) {
var singleline = delimiter.length == 1;
var OUTCLASS = 'string';
return function(stream, state) {
while (!stream.eol()) {
stream.eatWhile(/[^'"]/);
if (stream.match(delimiter)) {
state.tokenize = tokenBase;
return OUTCLASS;
} else {
stream.eat(/['"]/);
}
}
if (singleline) {
if (parserConf.singleLineStringErrors) {
return ERRORCLASS;
} else {
state.tokenize = tokenBase;
}
}
return OUTCLASS;
};
}
function tokenLexer(stream, state) {
var style = state.tokenize(stream, state);
var current = stream.current();
// Handle '.' connected identifiers
if (current === '.') {
style = state.tokenize(stream, state);
current = stream.current();
if (style.substr(0, 8) === 'variable' || style==='builtin' || style==='keyword'){//|| knownWords.indexOf(current.substring(1)) > -1) {
if (style === 'builtin' || style === 'keyword') style='variable';
if (knownWords.indexOf(current.substr(1)) > -1) style='variable-2';
return style;
} else {
return ERRORCLASS;
}
}
return style;
}
var external = {
electricChars:"dDpPtTfFeE ",
startState: function() {
return {
tokenize: tokenBase,
lastToken: null,
currentIndent: 0,
nextLineIndent: 0,
doInCurrentLine: false,
ignoreKeyword: false
};
},
token: function(stream, state) {
if (stream.sol()) {
state.currentIndent += state.nextLineIndent;
state.nextLineIndent = 0;
state.doInCurrentLine = 0;
}
var style = tokenLexer(stream, state);
state.lastToken = {style:style, content: stream.current()};
if (style==='space') style=null;
return style;
},
indent: function(state, textAfter) {
var trueText = textAfter.replace(/^\s+|\s+$/g, '') ;
if (trueText.match(closing) || trueText.match(doubleClosing) || trueText.match(middle)) return conf.indentUnit*(state.currentIndent-1);
if(state.currentIndent < 0) return 0;
return state.currentIndent * conf.indentUnit;
}
};
return external;
});
CodeMirror.defineMIME("text/vbscript", "vbscript");
CodeMirror.defineMode("xml", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag || true;

@@ -114,2 +115,3 @@ var Kludges = parserConfig.htmlMode ? {

state.tokenize = inAttribute(ch);
state.stringStartCol = stream.column();
return state.tokenize(stream, state);

@@ -123,3 +125,3 @@ } else {

function inAttribute(quote) {
return function(stream, state) {
var closure = function(stream, state) {
while (!stream.eol()) {

@@ -133,2 +135,4 @@ if (stream.next() == quote) {

};
closure.isInAttribute = true;
return closure;
}

@@ -305,6 +309,16 @@

var context = state.context;
// Indent multi-line strings (e.g. css).
if (state.tokenize.isInAttribute) {
return state.stringStartCol + 1;
}
if ((state.tokenize != inTag && state.tokenize != inText) ||
context && context.noIndent)
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
if (state.tagName) return state.tagStart + indentUnit * multilineTagIndentFactor;
// Indent the starts of attribute names.
if (state.tagName) {
if (multilineTagIndentPastTag)
return state.tagStart + state.tagName.length + 2;
else
return state.tagStart + indentUnit * multilineTagIndentFactor;
}
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;

@@ -323,3 +337,4 @@ if (context && /^<\//.test(textAfter))

configuration: parserConfig.htmlMode ? "html" : "xml"
configuration: parserConfig.htmlMode ? "html" : "xml",
helperType: parserConfig.htmlMode ? "html" : "xml"
};

@@ -326,0 +341,0 @@ });

{
"name": "codemirror",
"version":"3.14.1",
"version":"3.15.0",
"main": "lib/codemirror.js",

@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable",

@@ -187,3 +187,3 @@ /**

for (var i = 0; i < output.length; i += 2) {
s += '<td class="mt-style"><span>' + output[i] + '</span></td>';
s += '<td class="mt-style"><span>' + (output[i] || null) + '</span></td>';
}

@@ -190,0 +190,0 @@ s += '</table>';

@@ -502,2 +502,20 @@ var Pos = CodeMirror.Pos;

testCM("bookmarkCursor", function(cm) {
var pos01 = cm.cursorCoords(Pos(0, 1)), pos11 = cm.cursorCoords(Pos(1, 1)),
pos20 = cm.cursorCoords(Pos(2, 0)), pos30 = cm.cursorCoords(Pos(3, 0)),
pos41 = cm.cursorCoords(Pos(4, 1));
cm.setBookmark(Pos(0, 1), {widget: document.createTextNode("←"), insertLeft: true});
cm.setBookmark(Pos(2, 0), {widget: document.createTextNode("←"), insertLeft: true});
cm.setBookmark(Pos(1, 1), {widget: document.createTextNode("→")});
cm.setBookmark(Pos(3, 0), {widget: document.createTextNode("→")});
var new01 = cm.cursorCoords(Pos(0, 1)), new11 = cm.cursorCoords(Pos(1, 1)),
new20 = cm.cursorCoords(Pos(2, 0)), new30 = cm.cursorCoords(Pos(3, 0));
is(new01.left == pos01.left && new01.top == pos01.top, "at left, middle of line");
is(new11.left > pos11.left && new11.top == pos11.top, "at right, middle of line");
is(new20.left == pos20.left && new20.top == pos20.top, "at left, empty line");
is(new30.left > pos30.left && new30.top == pos30.top, "at right, empty line");
cm.setBookmark(Pos(4, 0), {widget: document.createTextNode("→")});
is(cm.cursorCoords(Pos(4, 1)).left > pos41.left, "single-char bug");
}, {value: "foo\nbar\n\n\nx\ny"});
testCM("getAllMarks", function(cm) {

@@ -827,2 +845,13 @@ addDoc(cm, 10, 10);

testCM("changedInlineWidget", function(cm) {
cm.setSize("10em");
var w = document.createElement("span");
w.innerHTML = "x";
var m = cm.markText(Pos(0, 4), Pos(0, 5), {replacedWith: w});
w.innerHTML = "and now the widget is really really long all of a sudden and a scrollbar is needed";
m.changed();
var hScroll = byClassName(cm.getWrapperElement(), "CodeMirror-hscrollbar")[0];
is(hScroll.scrollWidth > hScroll.clientWidth);
}, {value: "hello there"});
testCM("inlineWidget", function(cm) {

@@ -829,0 +858,0 @@ var w = cm.setBookmark(Pos(0, 2), {widget: document.createTextNode("uu")});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc