|
@@ -7,9 +7,13 @@ window.CodeMirror = (function() {
|
|
|
// Crude, but necessary to handle a number of hard-to-feature-detect
|
|
// Crude, but necessary to handle a number of hard-to-feature-detect
|
|
|
// bugs and behavior differences.
|
|
// bugs and behavior differences.
|
|
|
var gecko = /gecko\/\d/i.test(navigator.userAgent);
|
|
var gecko = /gecko\/\d/i.test(navigator.userAgent);
|
|
|
|
|
+ // IE11 currently doesn't count as 'ie', since it has almost none of
|
|
|
|
|
+ // the same bugs as earlier versions. Use ie_gt10 to handle
|
|
|
|
|
+ // incompatibilities in that version.
|
|
|
var ie = /MSIE \d/.test(navigator.userAgent);
|
|
var ie = /MSIE \d/.test(navigator.userAgent);
|
|
|
var ie_lt8 = ie && (document.documentMode == null || document.documentMode < 8);
|
|
var ie_lt8 = ie && (document.documentMode == null || document.documentMode < 8);
|
|
|
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
|
|
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
|
|
|
|
|
+ var ie_gt10 = /Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent);
|
|
|
var webkit = /WebKit\//.test(navigator.userAgent);
|
|
var webkit = /WebKit\//.test(navigator.userAgent);
|
|
|
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
|
|
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
|
|
|
var chrome = /Chrome\//.test(navigator.userAgent);
|
|
var chrome = /Chrome\//.test(navigator.userAgent);
|
|
@@ -353,8 +357,10 @@ window.CodeMirror = (function() {
|
|
|
d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
|
|
d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
|
|
|
} else d.gutterFiller.style.display = "";
|
|
} else d.gutterFiller.style.display = "";
|
|
|
|
|
|
|
|
- if (mac_geLion && scrollbarWidth(d.measure) === 0)
|
|
|
|
|
|
|
+ if (mac_geLion && scrollbarWidth(d.measure) === 0) {
|
|
|
d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
|
|
d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
|
|
|
|
|
+ d.scrollbarV.style.pointerEvents = d.scrollbarH.style.pointerEvents = "none";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function visibleLines(display, doc, viewPort) {
|
|
function visibleLines(display, doc, viewPort) {
|
|
@@ -529,6 +535,7 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
display.showingFrom = from; display.showingTo = to;
|
|
display.showingFrom = from; display.showingTo = to;
|
|
|
|
|
|
|
|
|
|
+ display.gutters.style.height = "";
|
|
|
updateHeightsInViewport(cm);
|
|
updateHeightsInViewport(cm);
|
|
|
updateViewOffset(cm);
|
|
updateViewOffset(cm);
|
|
|
|
|
|
|
@@ -711,9 +718,9 @@ window.CodeMirror = (function() {
|
|
|
if (bgClass)
|
|
if (bgClass)
|
|
|
wrap.insertBefore(elt("div", null, bgClass + " CodeMirror-linebackground"), wrap.firstChild);
|
|
wrap.insertBefore(elt("div", null, bgClass + " CodeMirror-linebackground"), wrap.firstChild);
|
|
|
if (cm.options.lineNumbers || markers) {
|
|
if (cm.options.lineNumbers || markers) {
|
|
|
- var gutterWrap = wrap.insertBefore(elt("div", null, null, "position: absolute; left: " +
|
|
|
|
|
|
|
+ var gutterWrap = wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "position: absolute; left: " +
|
|
|
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"),
|
|
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"),
|
|
|
- wrap.firstChild);
|
|
|
|
|
|
|
+ lineElement);
|
|
|
if (cm.options.fixedGutter) (wrap.alignable || (wrap.alignable = [])).push(gutterWrap);
|
|
if (cm.options.fixedGutter) (wrap.alignable || (wrap.alignable = [])).push(gutterWrap);
|
|
|
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
|
|
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
|
|
|
wrap.lineNumber = gutterWrap.appendChild(
|
|
wrap.lineNumber = gutterWrap.appendChild(
|
|
@@ -904,7 +911,7 @@ window.CodeMirror = (function() {
|
|
|
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.showingTo + 500), function(line) {
|
|
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.showingTo + 500), function(line) {
|
|
|
if (doc.frontier >= cm.display.showingFrom) { // Visible
|
|
if (doc.frontier >= cm.display.showingFrom) { // Visible
|
|
|
var oldStyles = line.styles;
|
|
var oldStyles = line.styles;
|
|
|
- line.styles = highlightLine(cm, line, state);
|
|
|
|
|
|
|
+ line.styles = highlightLine(cm, line, state, true);
|
|
|
var ischange = !oldStyles || oldStyles.length != line.styles.length;
|
|
var ischange = !oldStyles || oldStyles.length != line.styles.length;
|
|
|
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
|
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
|
|
if (ischange) {
|
|
if (ischange) {
|
|
@@ -913,7 +920,7 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
line.stateAfter = copyState(doc.mode, state);
|
|
line.stateAfter = copyState(doc.mode, state);
|
|
|
} else {
|
|
} else {
|
|
|
- processLine(cm, line, state);
|
|
|
|
|
|
|
+ processLine(cm, line.text, state);
|
|
|
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
|
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
|
|
}
|
|
}
|
|
|
++doc.frontier;
|
|
++doc.frontier;
|
|
@@ -935,8 +942,9 @@ window.CodeMirror = (function() {
|
|
|
// smallest indentation, which tends to need the least context to
|
|
// smallest indentation, which tends to need the least context to
|
|
|
// parse correctly.
|
|
// parse correctly.
|
|
|
function findStartLine(cm, n, precise) {
|
|
function findStartLine(cm, n, precise) {
|
|
|
- var minindent, minline, doc = cm.doc, maxScan = cm.doc.mode.innerMode ? 1000 : 100;
|
|
|
|
|
- for (var search = n, lim = n - maxScan; search > lim; --search) {
|
|
|
|
|
|
|
+ var minindent, minline, doc = cm.doc;
|
|
|
|
|
+ var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
|
|
|
|
|
+ for (var search = n; search > lim; --search) {
|
|
|
if (search <= doc.first) return doc.first;
|
|
if (search <= doc.first) return doc.first;
|
|
|
var line = getLine(doc, search - 1);
|
|
var line = getLine(doc, search - 1);
|
|
|
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
|
|
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
|
|
@@ -956,11 +964,12 @@ window.CodeMirror = (function() {
|
|
|
if (!state) state = startState(doc.mode);
|
|
if (!state) state = startState(doc.mode);
|
|
|
else state = copyState(doc.mode, state);
|
|
else state = copyState(doc.mode, state);
|
|
|
doc.iter(pos, n, function(line) {
|
|
doc.iter(pos, n, function(line) {
|
|
|
- processLine(cm, line, state);
|
|
|
|
|
|
|
+ processLine(cm, line.text, state);
|
|
|
var save = pos == n - 1 || pos % 5 == 0 || pos >= display.showingFrom && pos < display.showingTo;
|
|
var save = pos == n - 1 || pos % 5 == 0 || pos >= display.showingFrom && pos < display.showingTo;
|
|
|
line.stateAfter = save ? copyState(doc.mode, state) : null;
|
|
line.stateAfter = save ? copyState(doc.mode, state) : null;
|
|
|
++pos;
|
|
++pos;
|
|
|
});
|
|
});
|
|
|
|
|
+ if (precise) doc.frontier = pos;
|
|
|
return state;
|
|
return state;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1105,7 +1114,7 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (!rect) rect = data[i] = measureRect(getRect(node));
|
|
if (!rect) rect = data[i] = measureRect(getRect(node));
|
|
|
- if (cur.measureRight) rect.right = getRect(cur.measureRight).left;
|
|
|
|
|
|
|
+ if (cur.measureRight) rect.right = getRect(cur.measureRight).left - outer.left;
|
|
|
if (cur.leftSide) rect.leftSide = measureRect(getRect(cur.leftSide));
|
|
if (cur.leftSide) rect.leftSide = measureRect(getRect(cur.leftSide));
|
|
|
}
|
|
}
|
|
|
removeChildren(cm.display.measure);
|
|
removeChildren(cm.display.measure);
|
|
@@ -1379,11 +1388,14 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
if (!updated && op.selectionChanged) updateSelection(cm);
|
|
if (!updated && op.selectionChanged) updateSelection(cm);
|
|
|
if (op.updateScrollPos) {
|
|
if (op.updateScrollPos) {
|
|
|
- display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = newScrollPos.scrollTop;
|
|
|
|
|
- display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = newScrollPos.scrollLeft;
|
|
|
|
|
|
|
+ var top = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, newScrollPos.scrollTop));
|
|
|
|
|
+ var left = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, newScrollPos.scrollLeft));
|
|
|
|
|
+ display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = top;
|
|
|
|
|
+ display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = left;
|
|
|
alignHorizontally(cm);
|
|
alignHorizontally(cm);
|
|
|
if (op.scrollToPos)
|
|
if (op.scrollToPos)
|
|
|
- scrollPosIntoView(cm, clipPos(cm.doc, op.scrollToPos), op.scrollToPosMargin);
|
|
|
|
|
|
|
+ scrollPosIntoView(cm, clipPos(cm.doc, op.scrollToPos.from),
|
|
|
|
|
+ clipPos(cm.doc, op.scrollToPos.to), op.scrollToPos.margin);
|
|
|
} else if (newScrollPos) {
|
|
} else if (newScrollPos) {
|
|
|
scrollCursorIntoView(cm);
|
|
scrollCursorIntoView(cm);
|
|
|
}
|
|
}
|
|
@@ -1898,7 +1910,6 @@ window.CodeMirror = (function() {
|
|
|
if (cm.state.draggingText) replaceRange(cm.doc, "", curFrom, curTo, "paste");
|
|
if (cm.state.draggingText) replaceRange(cm.doc, "", curFrom, curTo, "paste");
|
|
|
cm.replaceSelection(text, null, "paste");
|
|
cm.replaceSelection(text, null, "paste");
|
|
|
focusInput(cm);
|
|
focusInput(cm);
|
|
|
- onFocus(cm);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
catch(e){}
|
|
catch(e){}
|
|
@@ -2179,13 +2190,17 @@ window.CodeMirror = (function() {
|
|
|
|
|
|
|
|
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
|
|
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
|
|
|
if (!pos || opera) return; // Opera is difficult.
|
|
if (!pos || opera) return; // Opera is difficult.
|
|
|
- if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Reset the current text selection only if the click is done outside of the selection
|
|
|
|
|
+ // and 'resetSelectionOnContextMenu' option is true.
|
|
|
|
|
+ var reset = cm.options.resetSelectionOnContextMenu;
|
|
|
|
|
+ if (reset && (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to)))
|
|
|
operation(cm, setSelection)(cm.doc, pos, pos);
|
|
operation(cm, setSelection)(cm.doc, pos, pos);
|
|
|
|
|
|
|
|
var oldCSS = display.input.style.cssText;
|
|
var oldCSS = display.input.style.cssText;
|
|
|
display.inputDiv.style.position = "absolute";
|
|
display.inputDiv.style.position = "absolute";
|
|
|
display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
|
|
display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
|
|
|
- "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: white; outline: none;" +
|
|
|
|
|
|
|
+ "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: transparent; outline: none;" +
|
|
|
"border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);";
|
|
"border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);";
|
|
|
focusInput(cm);
|
|
focusInput(cm);
|
|
|
resetInput(cm, true);
|
|
resetInput(cm, true);
|
|
@@ -2210,7 +2225,7 @@ window.CodeMirror = (function() {
|
|
|
if (!ie || ie_lt9) prepareSelectAllHack();
|
|
if (!ie || ie_lt9) prepareSelectAllHack();
|
|
|
clearTimeout(detectingSelectAll);
|
|
clearTimeout(detectingSelectAll);
|
|
|
var i = 0, poll = function(){
|
|
var i = 0, poll = function(){
|
|
|
- if (display.prevInput == " " && display.input.selectionStart == 0)
|
|
|
|
|
|
|
+ if (display.prevInput == "\u200b" && display.input.selectionStart == 0)
|
|
|
operation(cm, commands.selectAll)(cm);
|
|
operation(cm, commands.selectAll)(cm);
|
|
|
else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500);
|
|
else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500);
|
|
|
else resetInput(cm);
|
|
else resetInput(cm);
|
|
@@ -2630,7 +2645,7 @@ window.CodeMirror = (function() {
|
|
|
// SCROLLING
|
|
// SCROLLING
|
|
|
|
|
|
|
|
function scrollCursorIntoView(cm) {
|
|
function scrollCursorIntoView(cm) {
|
|
|
- var coords = scrollPosIntoView(cm, cm.doc.sel.head, cm.options.cursorScrollMargin);
|
|
|
|
|
|
|
+ var coords = scrollPosIntoView(cm, cm.doc.sel.head, null, cm.options.cursorScrollMargin);
|
|
|
if (!cm.state.focused) return;
|
|
if (!cm.state.focused) return;
|
|
|
var display = cm.display, box = getRect(display.sizer), doScroll = null;
|
|
var display = cm.display, box = getRect(display.sizer), doScroll = null;
|
|
|
if (coords.top + box.top < 0) doScroll = true;
|
|
if (coords.top + box.top < 0) doScroll = true;
|
|
@@ -2647,11 +2662,15 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function scrollPosIntoView(cm, pos, margin) {
|
|
|
|
|
|
|
+ function scrollPosIntoView(cm, pos, end, margin) {
|
|
|
if (margin == null) margin = 0;
|
|
if (margin == null) margin = 0;
|
|
|
for (;;) {
|
|
for (;;) {
|
|
|
var changed = false, coords = cursorCoords(cm, pos);
|
|
var changed = false, coords = cursorCoords(cm, pos);
|
|
|
- var scrollPos = calculateScrollPos(cm, coords.left, coords.top - margin, coords.left, coords.bottom + margin);
|
|
|
|
|
|
|
+ var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
|
|
|
|
|
+ var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
|
|
|
|
|
+ Math.min(coords.top, endCoords.top) - margin,
|
|
|
|
|
+ Math.max(coords.left, endCoords.left),
|
|
|
|
|
+ Math.max(coords.bottom, endCoords.bottom) + margin);
|
|
|
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
|
|
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
|
|
|
if (scrollPos.scrollTop != null) {
|
|
if (scrollPos.scrollTop != null) {
|
|
|
setScrollTop(cm, scrollPos.scrollTop);
|
|
setScrollTop(cm, scrollPos.scrollTop);
|
|
@@ -2748,6 +2767,8 @@ window.CodeMirror = (function() {
|
|
|
|
|
|
|
|
if (indentString != curSpaceString)
|
|
if (indentString != curSpaceString)
|
|
|
replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
|
|
replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
|
|
|
|
|
+ else if (doc.sel.head.line == n && doc.sel.head.ch < curSpaceString.length)
|
|
|
|
|
+ setSelection(doc, Pos(n, curSpaceString.length), Pos(n, curSpaceString.length), 1);
|
|
|
line.stateAfter = null;
|
|
line.stateAfter = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2848,7 +2869,7 @@ window.CodeMirror = (function() {
|
|
|
|
|
|
|
|
CodeMirror.prototype = {
|
|
CodeMirror.prototype = {
|
|
|
constructor: CodeMirror,
|
|
constructor: CodeMirror,
|
|
|
- focus: function(){window.focus(); focusInput(this); onFocus(this); fastPoll(this);},
|
|
|
|
|
|
|
+ focus: function(){window.focus(); focusInput(this); fastPoll(this);},
|
|
|
|
|
|
|
|
setOption: function(option, value) {
|
|
setOption: function(option, value) {
|
|
|
var options = this.options, old = options[option];
|
|
var options = this.options, old = options[option];
|
|
@@ -3169,17 +3190,23 @@ window.CodeMirror = (function() {
|
|
|
clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};
|
|
clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- scrollIntoView: operation(null, function(pos, margin) {
|
|
|
|
|
- if (typeof pos == "number") pos = Pos(pos, 0);
|
|
|
|
|
|
|
+ scrollIntoView: operation(null, function(range, margin) {
|
|
|
|
|
+ if (range == null) range = {from: this.doc.sel.head, to: null};
|
|
|
|
|
+ else if (typeof range == "number") range = {from: Pos(range, 0), to: null};
|
|
|
|
|
+ else if (range.from == null) range = {from: range, to: null};
|
|
|
|
|
+ if (!range.to) range.to = range.from;
|
|
|
if (!margin) margin = 0;
|
|
if (!margin) margin = 0;
|
|
|
- var coords = pos;
|
|
|
|
|
|
|
|
|
|
- if (!pos || pos.line != null) {
|
|
|
|
|
- this.curOp.scrollToPos = pos ? clipPos(this.doc, pos) : this.doc.sel.head;
|
|
|
|
|
- this.curOp.scrollToPosMargin = margin;
|
|
|
|
|
- coords = cursorCoords(this, this.curOp.scrollToPos);
|
|
|
|
|
|
|
+ var coords = range;
|
|
|
|
|
+ if (range.from.line != null) {
|
|
|
|
|
+ this.curOp.scrollToPos = {from: range.from, to: range.to, margin: margin};
|
|
|
|
|
+ coords = {from: cursorCoords(this, range.from),
|
|
|
|
|
+ to: cursorCoords(this, range.to)};
|
|
|
}
|
|
}
|
|
|
- var sPos = calculateScrollPos(this, coords.left, coords.top - margin, coords.right, coords.bottom + margin);
|
|
|
|
|
|
|
+ var sPos = calculateScrollPos(this, Math.min(coords.from.left, coords.to.left),
|
|
|
|
|
+ Math.min(coords.from.top, coords.to.top) - margin,
|
|
|
|
|
+ Math.max(coords.from.right, coords.to.right),
|
|
|
|
|
+ Math.max(coords.from.bottom, coords.to.bottom) + margin);
|
|
|
updateScrollPos(this, sPos.scrollLeft, sPos.scrollTop);
|
|
updateScrollPos(this, sPos.scrollLeft, sPos.scrollTop);
|
|
|
}),
|
|
}),
|
|
|
|
|
|
|
@@ -3211,6 +3238,7 @@ window.CodeMirror = (function() {
|
|
|
clearCaches(this);
|
|
clearCaches(this);
|
|
|
resetInput(this, true);
|
|
resetInput(this, true);
|
|
|
updateScrollPos(this, doc.scrollLeft, doc.scrollTop);
|
|
updateScrollPos(this, doc.scrollLeft, doc.scrollTop);
|
|
|
|
|
+ signalLater(this, "swapDoc", this, old);
|
|
|
return old;
|
|
return old;
|
|
|
}),
|
|
}),
|
|
|
|
|
|
|
@@ -3254,8 +3282,14 @@ window.CodeMirror = (function() {
|
|
|
clearCaches(cm);
|
|
clearCaches(cm);
|
|
|
regChange(cm);
|
|
regChange(cm);
|
|
|
}, true);
|
|
}, true);
|
|
|
|
|
+ option("specialChars", /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g, function(cm, val) {
|
|
|
|
|
+ cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
|
|
|
|
+ cm.refresh();
|
|
|
|
|
+ }, true);
|
|
|
|
|
+ option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
|
|
|
option("electricChars", true);
|
|
option("electricChars", true);
|
|
|
option("rtlMoveVisually", !windows);
|
|
option("rtlMoveVisually", !windows);
|
|
|
|
|
+ option("wholeLineUpdateBefore", true);
|
|
|
|
|
|
|
|
option("theme", "default", function(cm) {
|
|
option("theme", "default", function(cm) {
|
|
|
themeChanged(cm);
|
|
themeChanged(cm);
|
|
@@ -3285,9 +3319,17 @@ window.CodeMirror = (function() {
|
|
|
option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
|
|
option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
|
|
|
option("showCursorWhenSelecting", false, updateSelection, true);
|
|
option("showCursorWhenSelecting", false, updateSelection, true);
|
|
|
|
|
|
|
|
|
|
+ option("resetSelectionOnContextMenu", true);
|
|
|
|
|
+
|
|
|
option("readOnly", false, function(cm, val) {
|
|
option("readOnly", false, function(cm, val) {
|
|
|
- if (val == "nocursor") {onBlur(cm); cm.display.input.blur();}
|
|
|
|
|
- else if (!val) resetInput(cm, true);
|
|
|
|
|
|
|
+ if (val == "nocursor") {
|
|
|
|
|
+ onBlur(cm);
|
|
|
|
|
+ cm.display.input.blur();
|
|
|
|
|
+ cm.display.disabled = true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ cm.display.disabled = false;
|
|
|
|
|
+ if (!val) resetInput(cm, true);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
option("dragDrop", true);
|
|
option("dragDrop", true);
|
|
|
|
|
|
|
@@ -3668,11 +3710,12 @@ window.CodeMirror = (function() {
|
|
|
this.string = string;
|
|
this.string = string;
|
|
|
this.tabSize = tabSize || 8;
|
|
this.tabSize = tabSize || 8;
|
|
|
this.lastColumnPos = this.lastColumnValue = 0;
|
|
this.lastColumnPos = this.lastColumnValue = 0;
|
|
|
|
|
+ this.lineStart = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
StringStream.prototype = {
|
|
StringStream.prototype = {
|
|
|
eol: function() {return this.pos >= this.string.length;},
|
|
eol: function() {return this.pos >= this.string.length;},
|
|
|
- sol: function() {return this.pos == 0;},
|
|
|
|
|
|
|
+ sol: function() {return this.pos == this.lineStart;},
|
|
|
peek: function() {return this.string.charAt(this.pos) || undefined;},
|
|
peek: function() {return this.string.charAt(this.pos) || undefined;},
|
|
|
next: function() {
|
|
next: function() {
|
|
|
if (this.pos < this.string.length)
|
|
if (this.pos < this.string.length)
|
|
@@ -3705,9 +3748,12 @@ window.CodeMirror = (function() {
|
|
|
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
|
|
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
|
|
|
this.lastColumnPos = this.start;
|
|
this.lastColumnPos = this.start;
|
|
|
}
|
|
}
|
|
|
- return this.lastColumnValue;
|
|
|
|
|
|
|
+ return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
|
|
|
|
+ },
|
|
|
|
|
+ indentation: function() {
|
|
|
|
|
+ return countColumn(this.string, null, this.tabSize) -
|
|
|
|
|
+ (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
|
|
},
|
|
},
|
|
|
- indentation: function() {return countColumn(this.string, null, this.tabSize);},
|
|
|
|
|
match: function(pattern, consume, caseInsensitive) {
|
|
match: function(pattern, consume, caseInsensitive) {
|
|
|
if (typeof pattern == "string") {
|
|
if (typeof pattern == "string") {
|
|
|
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
|
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
|
@@ -3723,7 +3769,12 @@ window.CodeMirror = (function() {
|
|
|
return match;
|
|
return match;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- current: function(){return this.string.slice(this.start, this.pos);}
|
|
|
|
|
|
|
+ current: function(){return this.string.slice(this.start, this.pos);},
|
|
|
|
|
+ hideFirstChars: function(n, inner) {
|
|
|
|
|
+ this.lineStart += n;
|
|
|
|
|
+ try { return inner(); }
|
|
|
|
|
+ finally { this.lineStart -= n; }
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
CodeMirror.StringStream = StringStream;
|
|
CodeMirror.StringStream = StringStream;
|
|
|
|
|
|
|
@@ -3828,8 +3879,9 @@ window.CodeMirror = (function() {
|
|
|
if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
|
|
if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
|
|
|
|
|
|
|
|
var marker = new TextMarker(doc, type);
|
|
var marker = new TextMarker(doc, type);
|
|
|
- if (type == "range" && !posLess(from, to)) return marker;
|
|
|
|
|
if (options) copyObj(options, marker);
|
|
if (options) copyObj(options, marker);
|
|
|
|
|
+ if (posLess(to, from) || posEq(from, to) && marker.clearWhenEmpty !== false)
|
|
|
|
|
+ return marker;
|
|
|
if (marker.replacedWith) {
|
|
if (marker.replacedWith) {
|
|
|
marker.collapsed = true;
|
|
marker.collapsed = true;
|
|
|
marker.replacedWith = elt("span", [marker.replacedWith], "CodeMirror-widget");
|
|
marker.replacedWith = elt("span", [marker.replacedWith], "CodeMirror-widget");
|
|
@@ -3944,7 +3996,7 @@ window.CodeMirror = (function() {
|
|
|
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
|
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
|
|
var span = old[i], marker = span.marker;
|
|
var span = old[i], marker = span.marker;
|
|
|
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
|
|
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
|
|
|
- if (startsBefore || marker.type == "bookmark" && span.from == startCh && (!isInsert || !span.marker.insertLeft)) {
|
|
|
|
|
|
|
+ if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
|
|
|
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
|
|
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
|
|
|
(nw || (nw = [])).push({from: span.from,
|
|
(nw || (nw = [])).push({from: span.from,
|
|
|
to: endsAfter ? null : span.to,
|
|
to: endsAfter ? null : span.to,
|
|
@@ -3958,7 +4010,7 @@ window.CodeMirror = (function() {
|
|
|
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
|
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
|
|
var span = old[i], marker = span.marker;
|
|
var span = old[i], marker = span.marker;
|
|
|
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
|
|
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
|
|
|
- if (endsAfter || marker.type == "bookmark" && span.from == endCh && (!isInsert || span.marker.insertLeft)) {
|
|
|
|
|
|
|
+ if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
|
|
|
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
|
|
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
|
|
|
(nw || (nw = [])).push({from: startsBefore ? null : span.from - endCh,
|
|
(nw || (nw = [])).push({from: startsBefore ? null : span.from - endCh,
|
|
|
to: span.to == null ? null : span.to - endCh,
|
|
to: span.to == null ? null : span.to - endCh,
|
|
@@ -4008,13 +4060,9 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (sameLine && first) {
|
|
|
|
|
- // Make sure we didn't create any zero-length spans
|
|
|
|
|
- for (var i = 0; i < first.length; ++i)
|
|
|
|
|
- if (first[i].from != null && first[i].from == first[i].to && first[i].marker.type != "bookmark")
|
|
|
|
|
- first.splice(i--, 1);
|
|
|
|
|
- if (!first.length) first = null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Make sure we didn't create any zero-length spans
|
|
|
|
|
+ if (first) first = clearEmptySpans(first);
|
|
|
|
|
+ if (last && last != first) last = clearEmptySpans(last);
|
|
|
|
|
|
|
|
var newMarkers = [first];
|
|
var newMarkers = [first];
|
|
|
if (!sameLine) {
|
|
if (!sameLine) {
|
|
@@ -4031,6 +4079,16 @@ window.CodeMirror = (function() {
|
|
|
return newMarkers;
|
|
return newMarkers;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function clearEmptySpans(spans) {
|
|
|
|
|
+ for (var i = 0; i < spans.length; ++i) {
|
|
|
|
|
+ var span = spans[i];
|
|
|
|
|
+ if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
|
|
|
|
|
+ spans.splice(i--, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!spans.length) return null;
|
|
|
|
|
+ return spans;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function mergeOldSpans(doc, change) {
|
|
function mergeOldSpans(doc, change) {
|
|
|
var old = getOldSpans(doc, change);
|
|
var old = getOldSpans(doc, change);
|
|
|
var stretched = stretchSpansOverChange(doc, change);
|
|
var stretched = stretchSpansOverChange(doc, change);
|
|
@@ -4124,6 +4182,7 @@ window.CodeMirror = (function() {
|
|
|
for (var sp, i = 0; i < line.markedSpans.length; ++i) {
|
|
for (var sp, i = 0; i < line.markedSpans.length; ++i) {
|
|
|
sp = line.markedSpans[i];
|
|
sp = line.markedSpans[i];
|
|
|
if (sp.marker.collapsed && !sp.marker.replacedWith && sp.from == span.to &&
|
|
if (sp.marker.collapsed && !sp.marker.replacedWith && sp.from == span.to &&
|
|
|
|
|
+ (sp.to == null || sp.to != span.from) &&
|
|
|
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
|
|
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
|
|
|
lineIsHiddenInner(doc, line, sp)) return true;
|
|
lineIsHiddenInner(doc, line, sp)) return true;
|
|
|
}
|
|
}
|
|
@@ -4217,6 +4276,7 @@ window.CodeMirror = (function() {
|
|
|
this.height = estimateHeight ? estimateHeight(this) : 1;
|
|
this.height = estimateHeight ? estimateHeight(this) : 1;
|
|
|
};
|
|
};
|
|
|
eventMixin(Line);
|
|
eventMixin(Line);
|
|
|
|
|
+ Line.prototype.lineNo = function() { return lineNo(this); };
|
|
|
|
|
|
|
|
function updateLine(line, text, markedSpans, estimateHeight) {
|
|
function updateLine(line, text, markedSpans, estimateHeight) {
|
|
|
line.text = text;
|
|
line.text = text;
|
|
@@ -4237,7 +4297,7 @@ window.CodeMirror = (function() {
|
|
|
// Run the given mode's parser over a line, update the styles
|
|
// Run the given mode's parser over a line, update the styles
|
|
|
// array, which contains alternating fragments of text and CSS
|
|
// array, which contains alternating fragments of text and CSS
|
|
|
// classes.
|
|
// classes.
|
|
|
- function runMode(cm, text, mode, state, f) {
|
|
|
|
|
|
|
+ function runMode(cm, text, mode, state, f, forceToEnd) {
|
|
|
var flattenSpans = mode.flattenSpans;
|
|
var flattenSpans = mode.flattenSpans;
|
|
|
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
|
|
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
|
|
|
var curStart = 0, curStyle = null;
|
|
var curStart = 0, curStyle = null;
|
|
@@ -4246,6 +4306,7 @@ window.CodeMirror = (function() {
|
|
|
while (!stream.eol()) {
|
|
while (!stream.eol()) {
|
|
|
if (stream.pos > cm.options.maxHighlightLength) {
|
|
if (stream.pos > cm.options.maxHighlightLength) {
|
|
|
flattenSpans = false;
|
|
flattenSpans = false;
|
|
|
|
|
+ if (forceToEnd) processLine(cm, text, state, stream.pos);
|
|
|
stream.pos = text.length;
|
|
stream.pos = text.length;
|
|
|
style = null;
|
|
style = null;
|
|
|
} else {
|
|
} else {
|
|
@@ -4265,12 +4326,14 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function highlightLine(cm, line, state) {
|
|
|
|
|
|
|
+ function highlightLine(cm, line, state, forceToEnd) {
|
|
|
// A styles array always starts with a number identifying the
|
|
// A styles array always starts with a number identifying the
|
|
|
// mode/overlays that it is based on (for easy invalidation).
|
|
// mode/overlays that it is based on (for easy invalidation).
|
|
|
var st = [cm.state.modeGen];
|
|
var st = [cm.state.modeGen];
|
|
|
// Compute the base array of styles
|
|
// Compute the base array of styles
|
|
|
- runMode(cm, line.text, cm.doc.mode, state, function(end, style) {st.push(end, style);});
|
|
|
|
|
|
|
+ runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
|
|
|
|
|
+ st.push(end, style);
|
|
|
|
|
+ }, forceToEnd);
|
|
|
|
|
|
|
|
// Run overlays, adjust style array.
|
|
// Run overlays, adjust style array.
|
|
|
for (var o = 0; o < cm.state.overlays.length; ++o) {
|
|
for (var o = 0; o < cm.state.overlays.length; ++o) {
|
|
@@ -4309,10 +4372,11 @@ window.CodeMirror = (function() {
|
|
|
|
|
|
|
|
// Lightweight form of highlight -- proceed over this line and
|
|
// Lightweight form of highlight -- proceed over this line and
|
|
|
// update state, but don't save a style array.
|
|
// update state, but don't save a style array.
|
|
|
- function processLine(cm, line, state) {
|
|
|
|
|
|
|
+ function processLine(cm, text, state, startAt) {
|
|
|
var mode = cm.doc.mode;
|
|
var mode = cm.doc.mode;
|
|
|
- var stream = new StringStream(line.text, cm.options.tabSize);
|
|
|
|
|
- if (line.text == "" && mode.blankLine) mode.blankLine(state);
|
|
|
|
|
|
|
+ var stream = new StringStream(text, cm.options.tabSize);
|
|
|
|
|
+ stream.start = stream.pos = startAt || 0;
|
|
|
|
|
+ if (text == "" && mode.blankLine) mode.blankLine(state);
|
|
|
while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
|
|
while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
|
|
|
mode.token(stream, state);
|
|
mode.token(stream, state);
|
|
|
stream.start = stream.pos;
|
|
stream.start = stream.pos;
|
|
@@ -4369,7 +4433,7 @@ window.CodeMirror = (function() {
|
|
|
// Work around problem with the reported dimensions of single-char
|
|
// Work around problem with the reported dimensions of single-char
|
|
|
// direction spans on IE (issue #1129). See also the comment in
|
|
// direction spans on IE (issue #1129). See also the comment in
|
|
|
// cursorCoords.
|
|
// cursorCoords.
|
|
|
- if (measure && ie && (order = getOrder(line))) {
|
|
|
|
|
|
|
+ if (measure && (ie || ie_gt10) && (order = getOrder(line))) {
|
|
|
var l = order.length - 1;
|
|
var l = order.length - 1;
|
|
|
if (order[l].from == order[l].to) --l;
|
|
if (order[l].from == order[l].to) --l;
|
|
|
var last = order[l], prev = order[l - 1];
|
|
var last = order[l], prev = order[l - 1];
|
|
@@ -4387,17 +4451,23 @@ window.CodeMirror = (function() {
|
|
|
return builder;
|
|
return builder;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var tokenSpecialChars = /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;
|
|
|
|
|
|
|
+ function defaultSpecialCharPlaceholder(ch) {
|
|
|
|
|
+ var token = elt("span", "\u2022", "cm-invalidchar");
|
|
|
|
|
+ token.title = "\\u" + ch.charCodeAt(0).toString(16);
|
|
|
|
|
+ return token;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function buildToken(builder, text, style, startStyle, endStyle, title) {
|
|
function buildToken(builder, text, style, startStyle, endStyle, title) {
|
|
|
if (!text) return;
|
|
if (!text) return;
|
|
|
- if (!tokenSpecialChars.test(text)) {
|
|
|
|
|
|
|
+ var special = builder.cm.options.specialChars;
|
|
|
|
|
+ if (!special.test(text)) {
|
|
|
builder.col += text.length;
|
|
builder.col += text.length;
|
|
|
var content = document.createTextNode(text);
|
|
var content = document.createTextNode(text);
|
|
|
} else {
|
|
} else {
|
|
|
var content = document.createDocumentFragment(), pos = 0;
|
|
var content = document.createDocumentFragment(), pos = 0;
|
|
|
while (true) {
|
|
while (true) {
|
|
|
- tokenSpecialChars.lastIndex = pos;
|
|
|
|
|
- var m = tokenSpecialChars.exec(text);
|
|
|
|
|
|
|
+ special.lastIndex = pos;
|
|
|
|
|
+ var m = special.exec(text);
|
|
|
var skipped = m ? m.index - pos : text.length - pos;
|
|
var skipped = m ? m.index - pos : text.length - pos;
|
|
|
if (skipped) {
|
|
if (skipped) {
|
|
|
content.appendChild(document.createTextNode(text.slice(pos, pos + skipped)));
|
|
content.appendChild(document.createTextNode(text.slice(pos, pos + skipped)));
|
|
@@ -4410,8 +4480,7 @@ window.CodeMirror = (function() {
|
|
|
content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
|
|
content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
|
|
|
builder.col += tabWidth;
|
|
builder.col += tabWidth;
|
|
|
} else {
|
|
} else {
|
|
|
- var token = elt("span", "\u2022", "cm-invalidchar");
|
|
|
|
|
- token.title = "\\u" + m[0].charCodeAt(0).toString(16);
|
|
|
|
|
|
|
+ var token = builder.cm.options.specialCharPlaceholder(m[0]);
|
|
|
content.appendChild(token);
|
|
content.appendChild(token);
|
|
|
builder.col += 1;
|
|
builder.col += 1;
|
|
|
}
|
|
}
|
|
@@ -4462,7 +4531,7 @@ window.CodeMirror = (function() {
|
|
|
return out;
|
|
return out;
|
|
|
}
|
|
}
|
|
|
return function(builder, text, style, startStyle, endStyle, title) {
|
|
return function(builder, text, style, startStyle, endStyle, title) {
|
|
|
- return inner(builder, text.replace(/ {3,}/, split), style, startStyle, endStyle, title);
|
|
|
|
|
|
|
+ return inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -4564,7 +4633,8 @@ window.CodeMirror = (function() {
|
|
|
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
|
|
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
|
|
|
|
|
|
|
|
// First adjust the line structure
|
|
// First adjust the line structure
|
|
|
- if (from.ch == 0 && to.ch == 0 && lastText == "") {
|
|
|
|
|
|
|
+ if (from.ch == 0 && to.ch == 0 && lastText == "" &&
|
|
|
|
|
+ (!doc.cm || doc.cm.options.wholeLineUpdateBefore)) {
|
|
|
// This is a whole-line replace. Treated specially to make
|
|
// This is a whole-line replace. Treated specially to make
|
|
|
// sure line objects move the way they are supposed to.
|
|
// sure line objects move the way they are supposed to.
|
|
|
for (var i = 0, e = text.length - 1, added = []; i < e; ++i)
|
|
for (var i = 0, e = text.length - 1, added = []; i < e; ++i)
|
|
@@ -4871,7 +4941,8 @@ window.CodeMirror = (function() {
|
|
|
},
|
|
},
|
|
|
setBookmark: function(pos, options) {
|
|
setBookmark: function(pos, options) {
|
|
|
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
|
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
|
|
- insertLeft: options && options.insertLeft};
|
|
|
|
|
|
|
+ insertLeft: options && options.insertLeft,
|
|
|
|
|
+ clearWhenEmpty: false};
|
|
|
pos = clipPos(this, pos);
|
|
pos = clipPos(this, pos);
|
|
|
return markText(this, pos, pos, realOpts, "bookmark");
|
|
return markText(this, pos, pos, realOpts, "bookmark");
|
|
|
},
|
|
},
|
|
@@ -5451,7 +5522,7 @@ window.CodeMirror = (function() {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var isExtendingChar = /[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff]/;
|
|
|
|
|
|
|
+ var isExtendingChar = /[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\u1DC0-\u1DFF\u20D0-\u20FF\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff\uFE20-\uFE2F]/;
|
|
|
|
|
|
|
|
// DOM UTILITIES
|
|
// DOM UTILITIES
|
|
|
|
|
|
|
@@ -5524,7 +5595,7 @@ window.CodeMirror = (function() {
|
|
|
if (/\w/.test(str.charAt(i - 2)) && /[^\-?\.]/.test(str.charAt(i))) return true;
|
|
if (/\w/.test(str.charAt(i - 2)) && /[^\-?\.]/.test(str.charAt(i))) return true;
|
|
|
if (i > 2 && /[\d\.,]/.test(str.charAt(i - 2)) && /[\d\.,]/.test(str.charAt(i))) return false;
|
|
if (i > 2 && /[\d\.,]/.test(str.charAt(i - 2)) && /[\d\.,]/.test(str.charAt(i))) return false;
|
|
|
}
|
|
}
|
|
|
- return /[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|…[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
|
|
|
|
|
|
|
+ return /[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|\u2026[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
var knownScrollbarWidth;
|
|
var knownScrollbarWidth;
|
|
@@ -5656,22 +5727,22 @@ window.CodeMirror = (function() {
|
|
|
}
|
|
}
|
|
|
var bidiOther;
|
|
var bidiOther;
|
|
|
function getBidiPartAt(order, pos) {
|
|
function getBidiPartAt(order, pos) {
|
|
|
|
|
+ bidiOther = null;
|
|
|
for (var i = 0, found; i < order.length; ++i) {
|
|
for (var i = 0, found; i < order.length; ++i) {
|
|
|
var cur = order[i];
|
|
var cur = order[i];
|
|
|
- if (cur.from < pos && cur.to > pos) { bidiOther = null; return i; }
|
|
|
|
|
- if (cur.from == pos || cur.to == pos) {
|
|
|
|
|
|
|
+ if (cur.from < pos && cur.to > pos) return i;
|
|
|
|
|
+ if ((cur.from == pos || cur.to == pos)) {
|
|
|
if (found == null) {
|
|
if (found == null) {
|
|
|
found = i;
|
|
found = i;
|
|
|
} else if (compareBidiLevel(order, cur.level, order[found].level)) {
|
|
} else if (compareBidiLevel(order, cur.level, order[found].level)) {
|
|
|
- bidiOther = found;
|
|
|
|
|
|
|
+ if (cur.from != cur.to) bidiOther = found;
|
|
|
return i;
|
|
return i;
|
|
|
} else {
|
|
} else {
|
|
|
- bidiOther = i;
|
|
|
|
|
|
|
+ if (cur.from != cur.to) bidiOther = i;
|
|
|
return found;
|
|
return found;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- bidiOther = null;
|
|
|
|
|
return found;
|
|
return found;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -5805,7 +5876,7 @@ window.CodeMirror = (function() {
|
|
|
if (type == ",") types[i] = "N";
|
|
if (type == ",") types[i] = "N";
|
|
|
else if (type == "%") {
|
|
else if (type == "%") {
|
|
|
for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
|
|
for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
|
|
|
- var replace = (i && types[i-1] == "!") || (end < len - 1 && types[end] == "1") ? "1" : "N";
|
|
|
|
|
|
|
+ var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
|
|
|
for (var j = i; j < end; ++j) types[j] = replace;
|
|
for (var j = i; j < end; ++j) types[j] = replace;
|
|
|
i = end - 1;
|
|
i = end - 1;
|
|
|
}
|
|
}
|
|
@@ -5830,7 +5901,7 @@ window.CodeMirror = (function() {
|
|
|
if (isNeutral.test(types[i])) {
|
|
if (isNeutral.test(types[i])) {
|
|
|
for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
|
|
for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
|
|
|
var before = (i ? types[i-1] : outerType) == "L";
|
|
var before = (i ? types[i-1] : outerType) == "L";
|
|
|
- var after = (end < len - 1 ? types[end] : outerType) == "L";
|
|
|
|
|
|
|
+ var after = (end < len ? types[end] : outerType) == "L";
|
|
|
var replace = before || after ? "L" : "R";
|
|
var replace = before || after ? "L" : "R";
|
|
|
for (var j = i; j < end; ++j) types[j] = replace;
|
|
for (var j = i; j < end; ++j) types[j] = replace;
|
|
|
i = end - 1;
|
|
i = end - 1;
|
|
@@ -5880,7 +5951,7 @@ window.CodeMirror = (function() {
|
|
|
|
|
|
|
|
// THE END
|
|
// THE END
|
|
|
|
|
|
|
|
- CodeMirror.version = "3.18.1";
|
|
|
|
|
|
|
+ CodeMirror.version = "3.20.1";
|
|
|
|
|
|
|
|
return CodeMirror;
|
|
return CodeMirror;
|
|
|
})();
|
|
})();
|