CodeMirror 5.61.0

This commit is contained in:
tophf 2021-04-20 11:29:24 +03:00
parent afcd8ebcf4
commit 892b295897
7 changed files with 275 additions and 152 deletions

14
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "1.5.17", "version": "1.5.17",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"dependencies": { "dependencies": {
"codemirror": "5.60.0", "codemirror": "5.61.0",
"db-to-cloud": "^0.6.0", "db-to-cloud": "^0.6.0",
"jsonlint": "^1.6.3", "jsonlint": "^1.6.3",
"less-bundle": "github:openstyles/less-bundle#v0.1.0", "less-bundle": "github:openstyles/less-bundle#v0.1.0",
@ -2361,9 +2361,9 @@
} }
}, },
"node_modules/codemirror": { "node_modules/codemirror": {
"version": "5.60.0", "version": "5.61.0",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.60.0.tgz", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.61.0.tgz",
"integrity": "sha512-AEL7LhFOlxPlCL8IdTcJDblJm8yrAGib7I+DErJPdZd4l6imx8IMgKK3RblVgBQqz3TZJR4oknQ03bz+uNjBYA==" "integrity": "sha512-D3wYH90tYY1BsKlUe0oNj2JAhQ9TepkD51auk3N7q+4uz7A/cgJ5JsWHreT0PqieW1QhOuqxQ2reCXV1YXzecg=="
}, },
"node_modules/collection-visit": { "node_modules/collection-visit": {
"version": "1.0.0", "version": "1.0.0",
@ -13933,9 +13933,9 @@
} }
}, },
"codemirror": { "codemirror": {
"version": "5.60.0", "version": "5.61.0",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.60.0.tgz", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.61.0.tgz",
"integrity": "sha512-AEL7LhFOlxPlCL8IdTcJDblJm8yrAGib7I+DErJPdZd4l6imx8IMgKK3RblVgBQqz3TZJR4oknQ03bz+uNjBYA==" "integrity": "sha512-D3wYH90tYY1BsKlUe0oNj2JAhQ9TepkD51auk3N7q+4uz7A/cgJ5JsWHreT0PqieW1QhOuqxQ2reCXV1YXzecg=="
}, },
"collection-visit": { "collection-visit": {
"version": "1.0.0", "version": "1.0.0",

View File

@ -6,7 +6,7 @@
"repository": "openstyles/stylus", "repository": "openstyles/stylus",
"author": "Stylus Team", "author": "Stylus Team",
"dependencies": { "dependencies": {
"codemirror": "5.60.0", "codemirror": "5.61.0",
"db-to-cloud": "^0.6.0", "db-to-cloud": "^0.6.0",
"jsonlint": "^1.6.3", "jsonlint": "^1.6.3",
"less-bundle": "github:openstyles/less-bundle#v0.1.0", "less-bundle": "github:openstyles/less-bundle#v0.1.0",

View File

@ -1,4 +1,4 @@
## codemirror v5.60.0 ## codemirror v5.61.0
Following files are copied from npm (node_modules): Following files are copied from npm (node_modules):

View File

@ -293,6 +293,7 @@
} }
} }
var overlapX = box.right - winW; var overlapX = box.right - winW;
if (scrolls) overlapX += cm.display.nativeBarWidth;
if (overlapX > 0) { if (overlapX > 0) {
if (box.right - box.left > winW) { if (box.right - box.left > winW) {
hints.style.width = (winW - 5) + "px"; hints.style.width = (winW - 5) + "px";
@ -321,6 +322,7 @@
cm.on("scroll", this.onScroll = function() { cm.on("scroll", this.onScroll = function() {
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
if (!startScroll) startScroll = cm.getScrollInfo();
var newTop = top + startScroll.top - curScroll.top; var newTop = top + startScroll.top - curScroll.top;
var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop); var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop);
if (!below) point += hints.offsetHeight; if (!below) point += hints.offsetHeight;

View File

@ -11,6 +11,7 @@
})(function(CodeMirror) { })(function(CodeMirror) {
"use strict"; "use strict";
var cmds = CodeMirror.commands;
var Pos = CodeMirror.Pos; var Pos = CodeMirror.Pos;
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; } function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
@ -30,7 +31,8 @@
var lastKill = null; var lastKill = null;
function kill(cm, from, to, ring, text) { // Internal generic kill function, used by several mapped kill "family" functions.
function _kill(cm, from, to, ring, text) {
if (text == null) text = cm.getRange(from, to); if (text == null) text = cm.getRange(from, to);
if (ring == "grow" && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen)) if (ring == "grow" && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen))
@ -156,17 +158,17 @@
var i = selections.length; var i = selections.length;
while (i--) { while (i--) {
cursor = selections[i].head; cursor = selections[i].head;
kill(cm, cursor, findEnd(cm, cursor, by, dir), ring); _kill(cm, cursor, findEnd(cm, cursor, by, dir), ring);
} }
} }
function killRegion(cm, ring) { function _killRegion(cm, ring) {
if (cm.somethingSelected()) { if (cm.somethingSelected()) {
var selections = cm.listSelections(), selection; var selections = cm.listSelections(), selection;
var i = selections.length; var i = selections.length;
while (i--) { while (i--) {
selection = selections[i]; selection = selections[i];
kill(cm, selection.anchor, selection.head, ring); _kill(cm, selection.anchor, selection.head, ring);
} }
return true; return true;
} }
@ -205,13 +207,6 @@
} }
} }
function addPrefixMap(cm) {
cm.state.emacsPrefixMap = true;
cm.addKeyMap(prefixMap);
cm.on("keyHandled", maybeRemovePrefixMap);
cm.on("inputRead", maybeRemovePrefixMap);
}
function maybeRemovePrefixMap(cm, arg) { function maybeRemovePrefixMap(cm, arg) {
if (typeof arg == "string" && (/^\d$/.test(arg) || arg == "Ctrl-U")) return; if (typeof arg == "string" && (/^\d$/.test(arg) || arg == "Ctrl-U")) return;
cm.removeKeyMap(prefixMap); cm.removeKeyMap(prefixMap);
@ -222,7 +217,7 @@
// Utilities // Utilities
function setMark(cm) { cmds.setMark = function (cm) {
cm.setCursor(cm.getCursor()); cm.setCursor(cm.getCursor());
cm.setExtending(!cm.getExtending()); cm.setExtending(!cm.getExtending());
cm.on("change", function() { cm.setExtending(false); }); cm.on("change", function() { cm.setExtending(false); });
@ -276,118 +271,153 @@
} }
} }
function quit(cm) { // Commands. Names should match emacs function names (albeit in camelCase)
cm.execCommand("clearSearch"); // except where emacs function names collide with code mirror core commands.
clearMark(cm);
}
CodeMirror.emacs = {kill: kill, killRegion: killRegion, repeated: repeated}; cmds.killRegion = function(cm) {
_kill(cm, cm.getCursor("start"), cm.getCursor("end"), true);
};
// Actual keymap // Maps to emacs kill-line
cmds.killLineEmacs = repeated(function(cm) {
var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({
"Ctrl-W": function(cm) {kill(cm, cm.getCursor("start"), cm.getCursor("end"), true);},
"Ctrl-K": repeated(function(cm) {
var start = cm.getCursor(), end = cm.clipPos(Pos(start.line)); var start = cm.getCursor(), end = cm.clipPos(Pos(start.line));
var text = cm.getRange(start, end); var text = cm.getRange(start, end);
if (!/\S/.test(text)) { if (!/\S/.test(text)) {
text += "\n"; text += "\n";
end = Pos(start.line + 1, 0); end = Pos(start.line + 1, 0);
} }
kill(cm, start, end, "grow", text); _kill(cm, start, end, "grow", text);
}), });
"Alt-W": function(cm) {
cmds.killRingSave = function(cm) {
addToRing(cm.getSelection()); addToRing(cm.getSelection());
clearMark(cm); clearMark(cm);
}, };
"Ctrl-Y": function(cm) {
cmds.yank = function(cm) {
var start = cm.getCursor(); var start = cm.getCursor();
cm.replaceRange(getFromRing(getPrefix(cm)), start, start, "paste"); cm.replaceRange(getFromRing(getPrefix(cm)), start, start, "paste");
cm.setSelection(start, cm.getCursor()); cm.setSelection(start, cm.getCursor());
}, };
"Alt-Y": function(cm) {cm.replaceSelection(popFromRing(), "around", "paste");},
"Ctrl-Space": setMark, "Ctrl-Shift-2": setMark, cmds.yankPop = function(cm) {
cm.replaceSelection(popFromRing(), "around", "paste");
};
"Ctrl-F": move(byChar, 1), "Ctrl-B": move(byChar, -1), cmds.forwardChar = move(byChar, 1);
"Right": move(byChar, 1), "Left": move(byChar, -1),
"Ctrl-D": function(cm) { killTo(cm, byChar, 1, false); },
"Delete": function(cm) { killRegion(cm, false) || killTo(cm, byChar, 1, false); },
"Ctrl-H": function(cm) { killTo(cm, byChar, -1, false); },
"Backspace": function(cm) { killRegion(cm, false) || killTo(cm, byChar, -1, false); },
"Alt-F": move(byWord, 1), "Alt-B": move(byWord, -1), cmds.backwardChar = move(byChar, -1)
"Alt-Right": move(byWord, 1), "Alt-Left": move(byWord, -1),
"Alt-D": function(cm) { killTo(cm, byWord, 1, "grow"); },
"Alt-Backspace": function(cm) { killTo(cm, byWord, -1, "grow"); },
"Ctrl-N": move(byLine, 1), "Ctrl-P": move(byLine, -1), cmds.deleteChar = function(cm) { killTo(cm, byChar, 1, false); };
"Down": move(byLine, 1), "Up": move(byLine, -1),
"Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
"End": "goLineEnd", "Home": "goLineStart",
"Alt-V": move(byPage, -1), "Ctrl-V": move(byPage, 1), cmds.deleteForwardChar = function(cm) {
"PageUp": move(byPage, -1), "PageDown": move(byPage, 1), _killRegion(cm, false) || killTo(cm, byChar, 1, false);
};
"Ctrl-Up": move(byParagraph, -1), "Ctrl-Down": move(byParagraph, 1), cmds.deleteBackwardChar = function(cm) {
_killRegion(cm, false) || killTo(cm, byChar, -1, false);
};
"Alt-A": move(bySentence, -1), "Alt-E": move(bySentence, 1), cmds.forwardWord = move(byWord, 1);
"Alt-K": function(cm) { killTo(cm, bySentence, 1, "grow"); },
"Ctrl-Alt-K": function(cm) { killTo(cm, byExpr, 1, "grow"); }, cmds.backwardWord = move(byWord, -1);
"Ctrl-Alt-Backspace": function(cm) { killTo(cm, byExpr, -1, "grow"); },
"Ctrl-Alt-F": move(byExpr, 1), "Ctrl-Alt-B": move(byExpr, -1, "grow"),
"Shift-Ctrl-Alt-2": function(cm) { cmds.killWord = function(cm) { killTo(cm, byWord, 1, "grow"); };
cmds.backwardKillWord = function(cm) { killTo(cm, byWord, -1, "grow"); };
cmds.nextLine = move(byLine, 1);
cmds.previousLine = move(byLine, -1);
cmds.scrollDownCommand = move(byPage, 1);
cmds.scrollUpCommand = move(byPage, -1);
cmds.backwardParagraph = move(byParagraph, -1);
cmds.forwardParagraph = move(byParagraph, 1);
cmds.backwardSentence = move(bySentence, -1);
cmds.forwardSentence = move(bySentence, 1);
cmds.killSentence = function(cm) { killTo(cm, bySentence, 1, "grow"); };
cmds.backwardKillSentence = function(cm) {
_kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), "grow");
};
cmds.killSexp = function(cm) { killTo(cm, byExpr, 1, "grow"); };
cmds.backwardKillSexp = function(cm) { killTo(cm, byExpr, -1, "grow"); };
cmds.forwardSexp = move(byExpr, 1);
cmds.backwardSexp = move(byExpr, -1);
cmds.markSexp = function(cm) {
var cursor = cm.getCursor(); var cursor = cm.getCursor();
cm.setSelection(findEnd(cm, cursor, byExpr, 1), cursor); cm.setSelection(findEnd(cm, cursor, byExpr, 1), cursor);
}, };
"Ctrl-Alt-T": function(cm) {
var leftStart = byExpr(cm, cm.getCursor(), -1), leftEnd = byExpr(cm, leftStart, 1);
var rightEnd = byExpr(cm, leftEnd, 1), rightStart = byExpr(cm, rightEnd, -1);
cm.replaceRange(cm.getRange(rightStart, rightEnd) + cm.getRange(leftEnd, rightStart) +
cm.getRange(leftStart, leftEnd), leftStart, rightEnd);
},
"Ctrl-Alt-U": repeated(toEnclosingExpr),
"Alt-Space": function(cm) { cmds.transposeSexps = function(cm) {
var pos = cm.getCursor(), from = pos.ch, to = pos.ch, text = cm.getLine(pos.line); var leftStart = byExpr(cm, cm.getCursor(), -1);
var leftEnd = byExpr(cm, leftStart, 1);
var rightEnd = byExpr(cm, leftEnd, 1);
var rightStart = byExpr(cm, rightEnd, -1);
cm.replaceRange(cm.getRange(rightStart, rightEnd) +
cm.getRange(leftEnd, rightStart) +
cm.getRange(leftStart, leftEnd), leftStart, rightEnd);
};
cmds.backwardUpList = repeated(toEnclosingExpr);
cmds.justOneSpace = function(cm) {
var pos = cm.getCursor(), from = pos.ch;
var to = pos.ch, text = cm.getLine(pos.line);
while (from && /\s/.test(text.charAt(from - 1))) --from; while (from && /\s/.test(text.charAt(from - 1))) --from;
while (to < text.length && /\s/.test(text.charAt(to))) ++to; while (to < text.length && /\s/.test(text.charAt(to))) ++to;
cm.replaceRange(" ", Pos(pos.line, from), Pos(pos.line, to)); cm.replaceRange(" ", Pos(pos.line, from), Pos(pos.line, to));
}, };
"Ctrl-O": repeated(function(cm) { cm.replaceSelection("\n", "start"); }),
"Ctrl-T": repeated(function(cm) {
cm.execCommand("transposeChars");
}),
"Alt-C": repeated(function(cm) { cmds.openLine = repeated(function(cm) {
cm.replaceSelection("\n", "start");
});
// maps to emacs 'transpose-chars'
cmds.transposeCharsRepeatable = repeated(function(cm) {
cm.execCommand("transposeChars");
});
cmds.capitalizeWord = repeated(function(cm) {
operateOnWord(cm, function(w) { operateOnWord(cm, function(w) {
var letter = w.search(/\w/); var letter = w.search(/\w/);
if (letter == -1) return w; if (letter == -1) return w;
return w.slice(0, letter) + w.charAt(letter).toUpperCase() + w.slice(letter + 1).toLowerCase(); return w.slice(0, letter) + w.charAt(letter).toUpperCase() +
w.slice(letter + 1).toLowerCase();
}); });
}), });
"Alt-U": repeated(function(cm) {
cmds.upcaseWord = repeated(function(cm) {
operateOnWord(cm, function(w) { return w.toUpperCase(); }); operateOnWord(cm, function(w) { return w.toUpperCase(); });
}), });
"Alt-L": repeated(function(cm) {
cmds.downcaseWord = repeated(function(cm) {
operateOnWord(cm, function(w) { return w.toLowerCase(); }); operateOnWord(cm, function(w) { return w.toLowerCase(); });
}), });
"Alt-;": "toggleComment", // maps to emacs 'undo'
cmds.undoRepeatable = repeated("undo");
"Ctrl-/": repeated("undo"), "Shift-Ctrl--": repeated("undo"), cmds.keyboardQuit = function(cm) {
"Ctrl-Z": repeated("undo"), "Cmd-Z": repeated("undo"), cm.execCommand("clearSearch");
"Shift-Ctrl-Z": "redo", clearMark(cm);
"Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd", }
"Ctrl-S": "findPersistentNext", "Ctrl-R": "findPersistentPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
"Alt-/": "autocomplete",
"Enter": "newlineAndIndent",
"Ctrl-J": repeated(function(cm) { cm.replaceSelection("\n", "end"); }),
"Tab": "indentAuto",
"Alt-G G": function(cm) { cmds.newline = repeated(function(cm) { cm.replaceSelection("\n", "end"); });
cmds.gotoLine = function(cm) {
var prefix = getPrefix(cm, true); var prefix = getPrefix(cm, true);
if (prefix != null && prefix > 0) return cm.setCursor(prefix - 1); if (prefix != null && prefix > 0) return cm.setCursor(prefix - 1);
@ -396,25 +426,111 @@
if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0) if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0)
cm.setCursor(num - 1); cm.setCursor(num - 1);
}); });
}, };
"Ctrl-X Tab": function(cm) { cmds.indentRigidly = function(cm) {
cm.indentSelection(getPrefix(cm, true) || cm.getOption("indentUnit")); cm.indentSelection(getPrefix(cm, true) || cm.getOption("indentUnit"));
}, };
"Ctrl-X Ctrl-X": function(cm) {
cmds.exchangePointAndMark = function(cm) {
cm.setSelection(cm.getCursor("head"), cm.getCursor("anchor")); cm.setSelection(cm.getCursor("head"), cm.getCursor("anchor"));
}, };
cmds.quotedInsertTab = repeated("insertTab");
cmds.universalArgument = function addPrefixMap(cm) {
cm.state.emacsPrefixMap = true;
cm.addKeyMap(prefixMap);
cm.on("keyHandled", maybeRemovePrefixMap);
cm.on("inputRead", maybeRemovePrefixMap);
};
CodeMirror.emacs = {kill: _kill, killRegion: _killRegion, repeated: repeated};
// Actual keymap
var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({
"Ctrl-W": "killRegion",
"Ctrl-K": "killLineEmacs",
"Alt-W": "killRingSave",
"Ctrl-Y": "yank",
"Alt-Y": "yankPop",
"Ctrl-Space": "setMark",
"Ctrl-Shift-2": "setMark",
"Ctrl-F": "forwardChar",
"Ctrl-B": "backwardChar",
"Right": "forwardChar",
"Left": "backwardChar",
"Ctrl-D": "deleteChar",
"Delete": "deleteForwardChar",
"Ctrl-H": "deleteBackwardChar",
"Backspace": "deleteBackwardChar",
"Alt-F": "forwardWord",
"Alt-B": "backwardWord",
"Alt-Right": "forwardWord",
"Alt-Left": "backwardWord",
"Alt-D": "killWord",
"Alt-Backspace": "backwardKillWord",
"Ctrl-N": "nextLine",
"Ctrl-P": "previousLine",
"Down": "nextLine",
"Up": "previousLine",
"Ctrl-A": "goLineStart",
"Ctrl-E": "goLineEnd",
"End": "goLineEnd",
"Home": "goLineStart",
"Alt-V": "scrollDownCommand",
"Ctrl-V": "scrollUpCommand",
"PageUp": "scrollUpCommand",
"PageDown": "scrollDownCommand",
"Ctrl-Up": "backwardParagraph",
"Ctrl-Down": "forwardParagraph",
"Alt-{": "backwardParagraph",
"Alt-}": "forwardParagraph",
"Alt-A": "backwardSentence",
"Alt-E": "forwardSentence",
"Alt-K": "killSentence",
"Ctrl-X Delete": "backwardKillSentence",
"Ctrl-Alt-K": "killSexp",
"Ctrl-Alt-Backspace": "backwardKillSexp",
"Ctrl-Alt-F": "forwardSexp",
"Ctrl-Alt-B": "backwardSexp",
"Shift-Ctrl-Alt-2": "markSexp",
"Ctrl-Alt-T": "transposeSexps",
"Ctrl-Alt-U": "backwardUpList",
"Alt-Space": "justOneSpace",
"Ctrl-O": "openLine",
"Ctrl-T": "transposeCharsRepeatable",
"Alt-C": "capitalizeWord",
"Alt-U": "upcaseWord",
"Alt-L": "downcaseWord",
"Alt-;": "toggleComment",
"Ctrl-/": "undoRepeatable",
"Shift-Ctrl--": "undoRepeatable",
"Ctrl-Z": "undoRepeatable",
"Cmd-Z": "undoRepeatable",
"Ctrl-X U": "undoRepeatable",
"Shift-Ctrl-Z": "redo",
"Shift-Alt-,": "goDocStart",
"Shift-Alt-.": "goDocEnd",
"Ctrl-S": "findPersistentNext",
"Ctrl-R": "findPersistentPrev",
"Ctrl-G": "keyboardQuit",
"Shift-Alt-5": "replace",
"Alt-/": "autocomplete",
"Enter": "newlineAndIndent",
"Ctrl-J": "newline",
"Tab": "indentAuto",
"Alt-G G": "gotoLine",
"Ctrl-X Tab": "indentRigidly",
"Ctrl-X Ctrl-X": "exchangePointAndMark",
"Ctrl-X Ctrl-S": "save", "Ctrl-X Ctrl-S": "save",
"Ctrl-X Ctrl-W": "save", "Ctrl-X Ctrl-W": "save",
"Ctrl-X S": "saveAll", "Ctrl-X S": "saveAll",
"Ctrl-X F": "open", "Ctrl-X F": "open",
"Ctrl-X U": repeated("undo"),
"Ctrl-X K": "close", "Ctrl-X K": "close",
"Ctrl-X Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), "grow"); },
"Ctrl-X H": "selectAll", "Ctrl-X H": "selectAll",
"Ctrl-Q Tab": "quotedInsertTab",
"Ctrl-Q Tab": repeated("insertTab"), "Ctrl-U": "universalArgument",
"Ctrl-U": addPrefixMap,
"fallthrough": "default" "fallthrough": "default"
}); });

View File

@ -2186,6 +2186,7 @@
if (cm.options.lineNumbers || markers) { if (cm.options.lineNumbers || markers) {
var wrap$1 = ensureLineWrapped(lineView); var wrap$1 = ensureLineWrapped(lineView);
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px")); var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
gutterWrap.setAttribute("aria-hidden", "true");
cm.display.input.setUneditable(gutterWrap); cm.display.input.setUneditable(gutterWrap);
wrap$1.insertBefore(gutterWrap, lineView.text); wrap$1.insertBefore(gutterWrap, lineView.text);
if (lineView.line.gutterClass) if (lineView.line.gutterClass)
@ -4235,6 +4236,8 @@
function updateGutterSpace(display) { function updateGutterSpace(display) {
var width = display.gutters.offsetWidth; var width = display.gutters.offsetWidth;
display.sizer.style.marginLeft = width + "px"; display.sizer.style.marginLeft = width + "px";
// Send an event to consumers responding to changes in gutter width.
signalLater(display, "gutterChanged", display);
} }
function setDocumentHeight(cm, measure) { function setDocumentHeight(cm, measure) {
@ -6684,10 +6687,9 @@
// Very basic readline/emacs-style bindings, which are standard on Mac. // Very basic readline/emacs-style bindings, which are standard on Mac.
keyMap.emacsy = { keyMap.emacsy = {
"Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
"Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp",
"Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine",
"Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", "Ctrl-T": "transposeChars", "Ctrl-O": "openLine"
"Ctrl-O": "openLine"
}; };
keyMap.macDefault = { keyMap.macDefault = {
"Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
@ -8833,7 +8835,7 @@
var kludge = hiddenTextarea(), te = kludge.firstChild; var kludge = hiddenTextarea(), te = kludge.firstChild;
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
te.value = lastCopied.text.join("\n"); te.value = lastCopied.text.join("\n");
var hadFocus = document.activeElement; var hadFocus = activeElt();
selectInput(te); selectInput(te);
setTimeout(function () { setTimeout(function () {
cm.display.lineSpace.removeChild(kludge); cm.display.lineSpace.removeChild(kludge);
@ -8856,7 +8858,7 @@
ContentEditableInput.prototype.prepareSelection = function () { ContentEditableInput.prototype.prepareSelection = function () {
var result = prepareSelection(this.cm, false); var result = prepareSelection(this.cm, false);
result.focus = document.activeElement == this.div; result.focus = activeElt() == this.div;
return result return result
}; };
@ -8952,7 +8954,7 @@
ContentEditableInput.prototype.focus = function () { ContentEditableInput.prototype.focus = function () {
if (this.cm.options.readOnly != "nocursor") { if (this.cm.options.readOnly != "nocursor") {
if (!this.selectionInEditor() || document.activeElement != this.div) if (!this.selectionInEditor() || activeElt() != this.div)
{ this.showSelection(this.prepareSelection(), true); } { this.showSelection(this.prepareSelection(), true); }
this.div.focus(); this.div.focus();
} }
@ -9794,7 +9796,7 @@
addLegacyProps(CodeMirror); addLegacyProps(CodeMirror);
CodeMirror.version = "5.60.0"; CodeMirror.version = "5.61.0";
return CodeMirror; return CodeMirror;

View File

@ -16,6 +16,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var statementIndent = parserConfig.statementIndent; var statementIndent = parserConfig.statementIndent;
var jsonldMode = parserConfig.jsonld; var jsonldMode = parserConfig.jsonld;
var jsonMode = parserConfig.json || jsonldMode; var jsonMode = parserConfig.json || jsonldMode;
var trackScope = parserConfig.trackScope !== false
var isTS = parserConfig.typescript; var isTS = parserConfig.typescript;
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/; var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
@ -231,6 +232,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
} }
function inScope(state, varname) { function inScope(state, varname) {
if (!trackScope) return false
for (var v = state.localVars; v; v = v.next) for (var v = state.localVars; v; v = v.next)
if (v.name == varname) return true; if (v.name == varname) return true;
for (var cx = state.context; cx; cx = cx.prev) { for (var cx = state.context; cx; cx = cx.prev) {
@ -277,6 +279,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function register(varname) { function register(varname) {
var state = cx.state; var state = cx.state;
cx.marked = "def"; cx.marked = "def";
if (!trackScope) return
if (state.context) { if (state.context) {
if (state.lexical.info == "var" && state.context && state.context.block) { if (state.lexical.info == "var" && state.context && state.context.block) {
// FIXME function decls are also not block scoped // FIXME function decls are also not block scoped
@ -376,7 +379,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse); return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
} }
if (type == "function") return cont(functiondef); if (type == "function") return cont(functiondef);
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
if (type == "class" || (isTS && value == "interface")) { if (type == "class" || (isTS && value == "interface")) {
cx.marked = "keyword" cx.marked = "keyword"
return cont(pushlex("form", type == "class" ? type : value), className, poplex) return cont(pushlex("form", type == "class" ? type : value), className, poplex)
@ -883,7 +886,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
var c = state.cc[i]; var c = state.cc[i];
if (c == poplex) lexical = lexical.prev; if (c == poplex) lexical = lexical.prev;
else if (c != maybeelse) break; else if (c != maybeelse && c != popcontext) break;
} }
while ((lexical.type == "stat" || lexical.type == "form") && while ((lexical.type == "stat" || lexical.type == "form") &&
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) && (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&