mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-06 19:02:30 +01:00
Upgrade CodeMirror to 5.59.2
This should fix the following issue: - https://www.reddit.com/r/uBlockOrigin/comments/lnfyer/ CodeMirror was detecting Windows as iOS: - https://github.com/codemirror/CodeMirror/issues/6532
This commit is contained in:
parent
427eabb628
commit
0dfafc3bd3
10
src/lib/codemirror/addon/display/panel.js
vendored
10
src/lib/codemirror/addon/display/panel.js
vendored
@ -76,7 +76,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function initPanels(cm) {
|
function initPanels(cm) {
|
||||||
var wrap = cm.getWrapperElement();
|
var wrap = cm.getWrapperElement()
|
||||||
var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
|
var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
|
||||||
var height = parseInt(style.height);
|
var height = parseInt(style.height);
|
||||||
var info = cm.state.panels = {
|
var info = cm.state.panels = {
|
||||||
@ -84,9 +84,10 @@
|
|||||||
panels: [],
|
panels: [],
|
||||||
wrapper: document.createElement("div")
|
wrapper: document.createElement("div")
|
||||||
};
|
};
|
||||||
|
var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo()
|
||||||
wrap.parentNode.insertBefore(info.wrapper, wrap);
|
wrap.parentNode.insertBefore(info.wrapper, wrap);
|
||||||
var hasFocus = cm.hasFocus();
|
|
||||||
info.wrapper.appendChild(wrap);
|
info.wrapper.appendChild(wrap);
|
||||||
|
cm.scrollTo(scrollPos.left, scrollPos.top)
|
||||||
if (hasFocus) cm.focus();
|
if (hasFocus) cm.focus();
|
||||||
|
|
||||||
cm._setSize = cm.setSize;
|
cm._setSize = cm.setSize;
|
||||||
@ -114,8 +115,11 @@
|
|||||||
var info = cm.state.panels;
|
var info = cm.state.panels;
|
||||||
cm.state.panels = null;
|
cm.state.panels = null;
|
||||||
|
|
||||||
var wrap = cm.getWrapperElement();
|
var wrap = cm.getWrapperElement()
|
||||||
|
var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo()
|
||||||
info.wrapper.parentNode.replaceChild(wrap, info.wrapper);
|
info.wrapper.parentNode.replaceChild(wrap, info.wrapper);
|
||||||
|
cm.scrollTo(scrollPos.left, scrollPos.top)
|
||||||
|
if (hasFocus) cm.focus();
|
||||||
wrap.style.height = info.setHeight;
|
wrap.style.height = info.setHeight;
|
||||||
cm.setSize = cm._setSize;
|
cm.setSize = cm._setSize;
|
||||||
cm.setSize();
|
cm.setSize();
|
||||||
|
22
src/lib/codemirror/addon/edit/closebrackets.js
vendored
22
src/lib/codemirror/addon/edit/closebrackets.js
vendored
@ -87,7 +87,7 @@
|
|||||||
cm.operation(function() {
|
cm.operation(function() {
|
||||||
var linesep = cm.lineSeparator() || "\n";
|
var linesep = cm.lineSeparator() || "\n";
|
||||||
cm.replaceSelection(linesep + linesep, null);
|
cm.replaceSelection(linesep + linesep, null);
|
||||||
cm.execCommand("goCharLeft");
|
moveSel(cm, -1)
|
||||||
ranges = cm.listSelections();
|
ranges = cm.listSelections();
|
||||||
for (var i = 0; i < ranges.length; i++) {
|
for (var i = 0; i < ranges.length; i++) {
|
||||||
var line = ranges[i].head.line;
|
var line = ranges[i].head.line;
|
||||||
@ -97,6 +97,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function moveSel(cm, dir) {
|
||||||
|
var newRanges = [], ranges = cm.listSelections(), primary = 0
|
||||||
|
for (var i = 0; i < ranges.length; i++) {
|
||||||
|
var range = ranges[i]
|
||||||
|
if (range.head == cm.getCursor()) primary = i
|
||||||
|
var pos = range.head.ch || dir > 0 ? {line: range.head.line, ch: range.head.ch + dir} : {line: range.head.line - 1}
|
||||||
|
newRanges.push({anchor: pos, head: pos})
|
||||||
|
}
|
||||||
|
cm.setSelections(newRanges, primary)
|
||||||
|
}
|
||||||
|
|
||||||
function contractSelection(sel) {
|
function contractSelection(sel) {
|
||||||
var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
|
var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
|
||||||
return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
|
return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
|
||||||
@ -153,10 +164,9 @@
|
|||||||
var right = pos % 2 ? ch : pairs.charAt(pos + 1);
|
var right = pos % 2 ? ch : pairs.charAt(pos + 1);
|
||||||
cm.operation(function() {
|
cm.operation(function() {
|
||||||
if (type == "skip") {
|
if (type == "skip") {
|
||||||
cm.execCommand("goCharRight");
|
moveSel(cm, 1)
|
||||||
} else if (type == "skipThree") {
|
} else if (type == "skipThree") {
|
||||||
for (var i = 0; i < 3; i++)
|
moveSel(cm, 3)
|
||||||
cm.execCommand("goCharRight");
|
|
||||||
} else if (type == "surround") {
|
} else if (type == "surround") {
|
||||||
var sels = cm.getSelections();
|
var sels = cm.getSelections();
|
||||||
for (var i = 0; i < sels.length; i++)
|
for (var i = 0; i < sels.length; i++)
|
||||||
@ -169,10 +179,10 @@
|
|||||||
} else if (type == "both") {
|
} else if (type == "both") {
|
||||||
cm.replaceSelection(left + right, null);
|
cm.replaceSelection(left + right, null);
|
||||||
cm.triggerElectric(left + right);
|
cm.triggerElectric(left + right);
|
||||||
cm.execCommand("goCharLeft");
|
moveSel(cm, -1)
|
||||||
} else if (type == "addFour") {
|
} else if (type == "addFour") {
|
||||||
cm.replaceSelection(left + left + left + left, "before");
|
cm.replaceSelection(left + left + left + left, "before");
|
||||||
cm.execCommand("goCharRight");
|
moveSel(cm, 1)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
12
src/lib/codemirror/addon/edit/matchbrackets.js
vendored
12
src/lib/codemirror/addon/edit/matchbrackets.js
vendored
@ -38,7 +38,7 @@
|
|||||||
if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
|
if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
|
||||||
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
|
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
|
||||||
|
|
||||||
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
|
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style, config);
|
||||||
if (found == null) return null;
|
if (found == null) return null;
|
||||||
return {from: Pos(where.line, pos), to: found && found.pos,
|
return {from: Pos(where.line, pos), to: found && found.pos,
|
||||||
match: found && found.ch == match.charAt(0), forward: dir > 0};
|
match: found && found.ch == match.charAt(0), forward: dir > 0};
|
||||||
@ -67,7 +67,8 @@
|
|||||||
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
|
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
|
||||||
for (; pos != end; pos += dir) {
|
for (; pos != end; pos += dir) {
|
||||||
var ch = line.charAt(pos);
|
var ch = line.charAt(pos);
|
||||||
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
|
if (re.test(ch) && (style === undefined ||
|
||||||
|
(cm.getTokenTypeAt(Pos(lineNo, pos + 1)) || "") == (style || ""))) {
|
||||||
var match = matching[ch];
|
var match = matching[ch];
|
||||||
if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
|
if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
|
||||||
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
|
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
|
||||||
@ -80,11 +81,12 @@
|
|||||||
|
|
||||||
function matchBrackets(cm, autoclear, config) {
|
function matchBrackets(cm, autoclear, config) {
|
||||||
// Disable brace matching in long lines, since it'll cause hugely slow updates
|
// Disable brace matching in long lines, since it'll cause hugely slow updates
|
||||||
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
|
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000,
|
||||||
|
highlightNonMatching = config && config.highlightNonMatching;
|
||||||
var marks = [], ranges = cm.listSelections();
|
var marks = [], ranges = cm.listSelections();
|
||||||
for (var i = 0; i < ranges.length; i++) {
|
for (var i = 0; i < ranges.length; i++) {
|
||||||
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
|
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
|
||||||
if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
|
if (match && (match.match || highlightNonMatching !== false) && cm.getLine(match.from.line).length <= maxHighlightLen) {
|
||||||
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
|
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
|
||||||
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
|
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
|
||||||
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
|
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
|
||||||
@ -94,7 +96,7 @@
|
|||||||
|
|
||||||
if (marks.length) {
|
if (marks.length) {
|
||||||
// Kludge to work around the IE bug from issue #1193, where text
|
// Kludge to work around the IE bug from issue #1193, where text
|
||||||
// input stops going to the textare whever this fires.
|
// input stops going to the textarea whenever this fires.
|
||||||
if (ie_lt8 && cm.state.focused) cm.focus();
|
if (ie_lt8 && cm.state.focused) cm.focus();
|
||||||
|
|
||||||
var clear = function() {
|
var clear = function() {
|
||||||
|
16
src/lib/codemirror/addon/hint/show-hint.js
vendored
16
src/lib/codemirror/addon/hint/show-hint.js
vendored
@ -61,8 +61,10 @@
|
|||||||
this.startPos = this.cm.getCursor("start");
|
this.startPos = this.cm.getCursor("start");
|
||||||
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
||||||
|
|
||||||
var self = this;
|
if (this.options.updateOnCursorActivity) {
|
||||||
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
var self = this;
|
||||||
|
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
||||||
@ -75,7 +77,9 @@
|
|||||||
if (!this.active()) return;
|
if (!this.active()) return;
|
||||||
this.cm.state.completionActive = null;
|
this.cm.state.completionActive = null;
|
||||||
this.tick = null;
|
this.tick = null;
|
||||||
this.cm.off("cursorActivity", this.activityFunc);
|
if (this.options.updateOnCursorActivity) {
|
||||||
|
this.cm.off("cursorActivity", this.activityFunc);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
|
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
|
||||||
if (this.widget) this.widget.close();
|
if (this.widget) this.widget.close();
|
||||||
@ -117,9 +121,7 @@
|
|||||||
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
|
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
|
||||||
pos.ch < identStart.ch || this.cm.somethingSelected() ||
|
pos.ch < identStart.ch || this.cm.somethingSelected() ||
|
||||||
(!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
|
(!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
|
||||||
if (this.options.closeOnCursorActivity) {
|
this.close();
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.debounce = requestAnimationFrame(function() {self.update();});
|
this.debounce = requestAnimationFrame(function() {self.update();});
|
||||||
@ -492,9 +494,9 @@
|
|||||||
completeSingle: true,
|
completeSingle: true,
|
||||||
alignWithWord: true,
|
alignWithWord: true,
|
||||||
closeCharacters: /[\s()\[\]{};:>,]/,
|
closeCharacters: /[\s()\[\]{};:>,]/,
|
||||||
closeOnCursorActivity: true,
|
|
||||||
closeOnPick: true,
|
closeOnPick: true,
|
||||||
closeOnUnfocus: true,
|
closeOnUnfocus: true,
|
||||||
|
updateOnCursorActivity: true,
|
||||||
completeOnSingleClick: true,
|
completeOnSingleClick: true,
|
||||||
container: null,
|
container: null,
|
||||||
customKeys: null,
|
customKeys: null,
|
||||||
|
17
src/lib/codemirror/lib/codemirror.js
vendored
17
src/lib/codemirror/lib/codemirror.js
vendored
@ -32,7 +32,7 @@
|
|||||||
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
|
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
|
||||||
var phantom = /PhantomJS/.test(userAgent);
|
var phantom = /PhantomJS/.test(userAgent);
|
||||||
|
|
||||||
var ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
|
var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
|
||||||
var android = /Android/.test(userAgent);
|
var android = /Android/.test(userAgent);
|
||||||
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
||||||
var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
|
var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
|
||||||
@ -5115,7 +5115,7 @@
|
|||||||
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
||||||
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
|
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
|
||||||
|
|
||||||
if (!(options && options.scroll === false) && doc.cm)
|
if (!(options && options.scroll === false) && doc.cm && doc.cm.getOption("readOnly") != "nocursor")
|
||||||
{ ensureCursorVisible(doc.cm); }
|
{ ensureCursorVisible(doc.cm); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8675,10 +8675,13 @@
|
|||||||
function moveOnce(boundToLine) {
|
function moveOnce(boundToLine) {
|
||||||
var next;
|
var next;
|
||||||
if (unit == "codepoint") {
|
if (unit == "codepoint") {
|
||||||
var ch = lineObj.text.charCodeAt(pos.ch + (unit > 0 ? 0 : -1));
|
var ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1));
|
||||||
if (isNaN(ch)) { next = null; }
|
if (isNaN(ch)) {
|
||||||
else { next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (ch >= 0xD800 && ch < 0xDC00 ? 2 : 1))),
|
next = null;
|
||||||
-dir); }
|
} else {
|
||||||
|
var astral = dir > 0 ? ch >= 0xD800 && ch < 0xDC00 : ch >= 0xDC00 && ch < 0xDFFF;
|
||||||
|
next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir);
|
||||||
|
}
|
||||||
} else if (visually) {
|
} else if (visually) {
|
||||||
next = moveVisually(doc.cm, lineObj, pos, dir);
|
next = moveVisually(doc.cm, lineObj, pos, dir);
|
||||||
} else {
|
} else {
|
||||||
@ -9790,7 +9793,7 @@
|
|||||||
|
|
||||||
addLegacyProps(CodeMirror);
|
addLegacyProps(CodeMirror);
|
||||||
|
|
||||||
CodeMirror.version = "5.59.0";
|
CodeMirror.version = "5.59.2";
|
||||||
|
|
||||||
return CodeMirror;
|
return CodeMirror;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user