Skip to content

Commit

Permalink
upgraded to CodeMirror 5.36.0
Browse files Browse the repository at this point in the history
  • Loading branch information
w8tcha committed Mar 23, 2018
1 parent b40ac3c commit ff34e1e
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 71 deletions.
2 changes: 1 addition & 1 deletion codemirror/js/addon/edit/continuelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount);
var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber;

if (startIndent === nextIndent) {
if (startIndent === nextIndent && !isNaN(nextNumber)) {
if (newNumber === nextNumber) itemNumber = nextNumber + 1;
if (newNumber > nextNumber) itemNumber = newNumber + 1;
cm.replaceRange(
Expand Down
8 changes: 5 additions & 3 deletions codemirror/js/addon/hint/javascript-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
// Find the token at the cursor
var cur = editor.getCursor(), token = getToken(editor, cur);
if (/\b(?:string|comment)\b/.test(token.type)) return;
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
var innerMode = CodeMirror.innerMode(editor.getMode(), token.state);
if (innerMode.mode.helperType === "json") return;
token.state = innerMode.state;

// If it's not a 'word-style' token, ignore the token.
if (!/^[\w$_]*$/.test(token.string)) {
Expand Down Expand Up @@ -92,8 +94,8 @@
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
var funcProps = "prototype apply call bind".split(" ");
var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
var javascriptKeywords = ("break case catch class const continue debugger default delete do else export extends false finally for function " +
"if in import instanceof new null return super switch this throw true try typeof var void while with yield").split(" ");
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");

Expand Down
11 changes: 6 additions & 5 deletions codemirror/js/addon/hint/show-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,13 @@
});

CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
var to = CodeMirror.Pos(cur.line, token.end);
if (token.string && /\w/.test(token.string[token.string.length - 1])) {
var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
var cur = cm.getCursor(), token = cm.getTokenAt(cur)
var term, from = CodeMirror.Pos(cur.line, token.start), to = cur
if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) {
term = token.string.substr(0, cur.ch - token.start)
} else {
var term = "", from = to;
term = ""
from = cur
}
var found = [];
for (var i = 0; i < options.words.length; i++) {
Expand Down
10 changes: 9 additions & 1 deletion codemirror/js/addon/mode/multiplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
if (found == stream.pos) {
if (!other.parseDelimiters) stream.match(other.open);
state.innerActive = other;
state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);

// Get the outer indent, making sure to handle CodeMirror.Pass
var outerIndent = 0;
if (outer.indent) {
var possibleOuterIndent = outer.indent(state.outer, "");
if (possibleOuterIndent !== CodeMirror.Pass) outerIndent = possibleOuterIndent;
}

state.inner = CodeMirror.startState(other.mode, outerIndent);
return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open");
} else if (found != -1 && found < cutOff) {
cutOff = found;
Expand Down
2 changes: 1 addition & 1 deletion codemirror/js/addon/search/match-highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
var state = cm.state.matchHighlighter;
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
var searchFor = hasBoundary ? new RegExp("\\b" + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + "\\b") : query;
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
{className: "CodeMirror-selection-highlight-scrollbar"});
}
Expand Down
18 changes: 11 additions & 7 deletions codemirror/js/addon/search/searchcursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@
+ (regexp.multiline ? "m" : "")
}

function ensureGlobal(regexp) {
return regexp.global ? regexp : new RegExp(regexp.source, regexpFlags(regexp) + "g")
function ensureFlags(regexp, flags) {
var current = regexpFlags(regexp), target = current
for (var i = 0; i < flags.length; i++) if (target.indexOf(flags.charAt(i)) == -1)
target += flags.charAt(i)
return current == target ? regexp : new RegExp(regexp.source, target)
}

function maybeMultiline(regexp) {
return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source)
}

function searchRegexpForward(doc, regexp, start) {
regexp = ensureGlobal(regexp)
regexp = ensureFlags(regexp, "g")
for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) {
regexp.lastIndex = ch
var string = doc.getLine(line), match = regexp.exec(string)
Expand All @@ -42,7 +45,7 @@
function searchRegexpForwardMultiline(doc, regexp, start) {
if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start)

regexp = ensureGlobal(regexp)
regexp = ensureFlags(regexp, "gm")
var string, chunk = 1
for (var line = start.line, last = doc.lastLine(); line <= last;) {
// This grows the search buffer in exponentially-sized chunks
Expand All @@ -51,6 +54,7 @@
// searching for something that has tons of matches), but at the
// same time, the amount of retries is limited.
for (var i = 0; i < chunk; i++) {
if (line > last) break
var curLine = doc.getLine(line++)
string = string == null ? curLine : string + "\n" + curLine
}
Expand Down Expand Up @@ -81,7 +85,7 @@
}

function searchRegexpBackward(doc, regexp, start) {
regexp = ensureGlobal(regexp)
regexp = ensureFlags(regexp, "g")
for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) {
var string = doc.getLine(line)
if (ch > -1) string = string.slice(0, ch)
Expand All @@ -94,7 +98,7 @@
}

function searchRegexpBackwardMultiline(doc, regexp, start) {
regexp = ensureGlobal(regexp)
regexp = ensureFlags(regexp, "gm")
var string, chunk = 1
for (var line = start.line, first = doc.firstLine(); line >= first;) {
for (var i = 0; i < chunk; i++) {
Expand Down Expand Up @@ -213,7 +217,7 @@
return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold)
}
} else {
query = ensureGlobal(query)
query = ensureFlags(query, "gm")
if (!options || options.multiline !== false)
this.matches = function(reverse, pos) {
return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos)
Expand Down
4 changes: 2 additions & 2 deletions codemirror/js/codemirror.addons.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codemirror/js/codemirror.addons.search.min.js

Large diffs are not rendered by default.

50 changes: 29 additions & 21 deletions codemirror/js/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -4783,7 +4783,7 @@ function addChangeToHistory(doc, change, selAfter, opId) {

if ((hist.lastOp == opId ||
hist.lastOrigin == change.origin && change.origin &&
((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||
change.origin.charAt(0) == "*")) &&
(cur = lastChangeEvent(hist, hist.lastOp == opId))) {
// Merge this change into the last event
Expand Down Expand Up @@ -5212,7 +5212,8 @@ function makeChangeInner(doc, change) {

// Revert a change stored in a document's history.
function makeChangeFromHistory(doc, type, allowSelectionOnly) {
if (doc.cm && doc.cm.state.suppressEdits && !allowSelectionOnly) { return }
var suppress = doc.cm && doc.cm.state.suppressEdits
if (suppress && !allowSelectionOnly) { return }

var hist = doc.history, event, selAfter = doc.sel
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done
Expand All @@ -5237,8 +5238,10 @@ function makeChangeFromHistory(doc, type, allowSelectionOnly) {
return
}
selAfter = event
}
else { break }
} else if (suppress) {
source.push(event)
return
} else { break }
}

// Build up a reverse change object to add to the opposite history
Expand Down Expand Up @@ -5714,7 +5717,7 @@ function addLineWidget(doc, handle, node, options) {
}
return true
})
signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle))
if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)) }
return widget
}

Expand Down Expand Up @@ -7309,8 +7312,8 @@ function leftButtonStartDrag(cm, event, pos, behavior) {
var dragEnd = operation(cm, function (e) {
if (webkit) { display.scroller.draggable = false }
cm.state.draggingText = false
off(document, "mouseup", dragEnd)
off(document, "mousemove", mouseMove)
off(display.wrapper.ownerDocument, "mouseup", dragEnd)
off(display.wrapper.ownerDocument, "mousemove", mouseMove)
off(display.scroller, "dragstart", dragStart)
off(display.scroller, "drop", dragEnd)
if (!moved) {
Expand All @@ -7319,7 +7322,7 @@ function leftButtonStartDrag(cm, event, pos, behavior) {
{ extendSelection(cm.doc, pos, null, null, behavior.extend) }
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
if (webkit || ie && ie_version == 9)
{ setTimeout(function () {document.body.focus(); display.input.focus()}, 20) }
{ setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus()}, 20) }
else
{ display.input.focus() }
}
Expand All @@ -7334,8 +7337,8 @@ function leftButtonStartDrag(cm, event, pos, behavior) {
dragEnd.copy = !behavior.moveOnDrag
// IE's approach to draggable
if (display.scroller.dragDrop) { display.scroller.dragDrop() }
on(document, "mouseup", dragEnd)
on(document, "mousemove", mouseMove)
on(display.wrapper.ownerDocument, "mouseup", dragEnd)
on(display.wrapper.ownerDocument, "mousemove", mouseMove)
on(display.scroller, "dragstart", dragStart)
on(display.scroller, "drop", dragEnd)

Expand Down Expand Up @@ -7467,8 +7470,8 @@ function leftButtonSelect(cm, event, start, behavior) {
counter = Infinity
e_preventDefault(e)
display.input.focus()
off(document, "mousemove", move)
off(document, "mouseup", up)
off(display.wrapper.ownerDocument, "mousemove", move)
off(display.wrapper.ownerDocument, "mouseup", up)
doc.history.lastSelOrigin = null
}

Expand All @@ -7478,8 +7481,8 @@ function leftButtonSelect(cm, event, start, behavior) {
})
var up = operation(cm, done)
cm.state.selectingText = up
on(document, "mousemove", move)
on(document, "mouseup", up)
on(display.wrapper.ownerDocument, "mousemove", move)
on(display.wrapper.ownerDocument, "mouseup", up)
}

// Used when mouse-selecting to adjust the anchor to the proper side
Expand Down Expand Up @@ -9184,13 +9187,10 @@ TextareaInput.prototype.init = function (display) {
var this$1 = this;

var input = this, cm = this.cm
this.createField(display)
var te = this.textarea

// Wraps and hides input textarea
var div = this.wrapper = hiddenTextarea()
// The semihidden textarea that is focused when the editor is
// focused, and receives input.
var te = this.textarea = div.firstChild
display.wrapper.insertBefore(div, display.wrapper.firstChild)
display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild)

// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
if (ios) { te.style.width = "0px" }
Expand Down Expand Up @@ -9257,6 +9257,14 @@ TextareaInput.prototype.init = function (display) {
})
};

TextareaInput.prototype.createField = function (_display) {
// Wraps and hides input textarea
this.wrapper = hiddenTextarea()
// The semihidden textarea that is focused when the editor is
// focused, and receives input.
this.textarea = this.wrapper.firstChild
};

TextareaInput.prototype.prepareSelection = function () {
// Redraw the selection and/or cursor
var cm = this.cm, display = cm.display, doc = cm.doc
Expand Down Expand Up @@ -9650,7 +9658,7 @@ CodeMirror.fromTextArea = fromTextArea

addLegacyProps(CodeMirror)

CodeMirror.version = "5.34.0"
CodeMirror.version = "5.36.0"

return CodeMirror;

Expand Down
6 changes: 0 additions & 6 deletions codemirror/js/codemirror.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion codemirror/js/codemirror.mode.bbcodemixed.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions codemirror/js/codemirror.mode.htmlmixed.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit ff34e1e

Please sign in to comment.