From b00e6d23fe5cda4f95c5f2c121bd1eb434a2d14c Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 10 Jan 2021 13:02:20 +0300 Subject: [PATCH] revert CodeMirror to 5.59.0 5.59.1 is bugged https://github.com/codemirror/CodeMirror/issues/6558 --- package-lock.json | 14 ++++++------ package.json | 2 +- vendor/codemirror/README.md | 2 +- vendor/codemirror/addon/edit/closebrackets.js | 22 +++++-------------- vendor/codemirror/lib/codemirror.js | 13 +++++------ .../codemirror/mode/javascript/javascript.js | 9 +++----- 6 files changed, 23 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index a1605916..bcbf50b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.5.14", "license": "GPL-3.0-only", "dependencies": { - "codemirror": "^5.59.1", + "codemirror": "5.59.0", "db-to-cloud": "^0.4.5", "jsonlint": "^1.6.3", "less-bundle": "github:openstyles/less-bundle#v0.1.0", @@ -2364,9 +2364,9 @@ } }, "node_modules/codemirror": { - "version": "5.59.1", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.59.1.tgz", - "integrity": "sha512-d0SSW/PCCD4LoSCBPdnP0BzmZB1v3emomCUtVlIWgZHJ06yVeBOvBtOH7vYz707pfAvEeWbO9aP6akh8vl1V3w==" + "version": "5.59.0", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.59.0.tgz", + "integrity": "sha512-UGzSkCacY9z0rSpQ3wnTWRN2nvRE6foDXnJltWW8pazInR/R+3gXHrao4IFQMv/bSBvFBxt8/HPpkpKAS54x5Q==" }, "node_modules/collection-visit": { "version": "1.0.0", @@ -13958,9 +13958,9 @@ } }, "codemirror": { - "version": "5.59.1", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.59.1.tgz", - "integrity": "sha512-d0SSW/PCCD4LoSCBPdnP0BzmZB1v3emomCUtVlIWgZHJ06yVeBOvBtOH7vYz707pfAvEeWbO9aP6akh8vl1V3w==" + "version": "5.59.0", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.59.0.tgz", + "integrity": "sha512-UGzSkCacY9z0rSpQ3wnTWRN2nvRE6foDXnJltWW8pazInR/R+3gXHrao4IFQMv/bSBvFBxt8/HPpkpKAS54x5Q==" }, "collection-visit": { "version": "1.0.0", diff --git a/package.json b/package.json index 119d6505..70795807 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "repository": "openstyles/stylus", "author": "Stylus Team", "dependencies": { - "codemirror": "^5.59.1", + "codemirror": "5.59.0", "db-to-cloud": "^0.4.5", "jsonlint": "^1.6.3", "less-bundle": "github:openstyles/less-bundle#v0.1.0", diff --git a/vendor/codemirror/README.md b/vendor/codemirror/README.md index 435d4dd2..accdd608 100644 --- a/vendor/codemirror/README.md +++ b/vendor/codemirror/README.md @@ -1,4 +1,4 @@ -## codemirror v5.59.1 +## codemirror v5.59.0 Following files are copied from npm (node_modules): diff --git a/vendor/codemirror/addon/edit/closebrackets.js b/vendor/codemirror/addon/edit/closebrackets.js index 5c1aeab3..4415c393 100644 --- a/vendor/codemirror/addon/edit/closebrackets.js +++ b/vendor/codemirror/addon/edit/closebrackets.js @@ -87,7 +87,7 @@ cm.operation(function() { var linesep = cm.lineSeparator() || "\n"; cm.replaceSelection(linesep + linesep, null); - moveSel(cm, -1) + cm.execCommand("goCharLeft"); ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { var line = ranges[i].head.line; @@ -97,17 +97,6 @@ }); } - 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 = {line: range.head.line, ch: range.head.ch + dir} - newRanges.push({anchor: pos, head: pos}) - } - cm.setSelections(newRanges, primary) - } - function contractSelection(sel) { var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0; return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)), @@ -164,9 +153,10 @@ var right = pos % 2 ? ch : pairs.charAt(pos + 1); cm.operation(function() { if (type == "skip") { - moveSel(cm, 1) + cm.execCommand("goCharRight"); } else if (type == "skipThree") { - moveSel(cm, 3) + for (var i = 0; i < 3; i++) + cm.execCommand("goCharRight"); } else if (type == "surround") { var sels = cm.getSelections(); for (var i = 0; i < sels.length; i++) @@ -179,10 +169,10 @@ } else if (type == "both") { cm.replaceSelection(left + right, null); cm.triggerElectric(left + right); - moveSel(cm, -1) + cm.execCommand("goCharLeft"); } else if (type == "addFour") { cm.replaceSelection(left + left + left + left, "before"); - moveSel(cm, 1) + cm.execCommand("goCharRight"); } }); } diff --git a/vendor/codemirror/lib/codemirror.js b/vendor/codemirror/lib/codemirror.js index 149b6fd9..cb218678 100644 --- a/vendor/codemirror/lib/codemirror.js +++ b/vendor/codemirror/lib/codemirror.js @@ -32,7 +32,7 @@ var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); var phantom = /PhantomJS/.test(userAgent); - var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2); + var ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2); var android = /Android/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); @@ -8676,12 +8676,9 @@ var next; if (unit == "codepoint") { var ch = lineObj.text.charCodeAt(pos.ch + (unit > 0 ? 0 : -1)); - if (isNaN(ch)) { - next = null; - } 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); - } + if (isNaN(ch)) { next = null; } + else { next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (ch >= 0xD800 && ch < 0xDC00 ? 2 : 1))), + -dir); } } else if (visually) { next = moveVisually(doc.cm, lineObj, pos, dir); } else { @@ -9793,7 +9790,7 @@ addLegacyProps(CodeMirror); - CodeMirror.version = "5.59.1"; + CodeMirror.version = "5.59.0"; return CodeMirror; diff --git a/vendor/codemirror/mode/javascript/javascript.js b/vendor/codemirror/mode/javascript/javascript.js index 966ffef0..188dbf21 100644 --- a/vendor/codemirror/mode/javascript/javascript.js +++ b/vendor/codemirror/mode/javascript/javascript.js @@ -640,8 +640,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) } else if (type == "(") { return pass(functiondecl, typeprop) - } else if (!type.match(/[;\}\)\],]/)) { - return cont() } } function typearg(type, value) { @@ -932,10 +930,9 @@ CodeMirror.defineMIME("text/ecmascript", "javascript"); CodeMirror.defineMIME("application/javascript", "javascript"); CodeMirror.defineMIME("application/x-javascript", "javascript"); CodeMirror.defineMIME("application/ecmascript", "javascript"); -CodeMirror.defineMIME("application/json", { name: "javascript", json: true }); -CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true }); -CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true }) -CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true }); +CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); +CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); +CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });