Skip to content

Commit 78dfe73

Browse files
committed
Upgraded to CodeMirror 5.43.0
1 parent 0c20128 commit 78dfe73

25 files changed

+252
-142
lines changed

codemirror/js/addon/edit/matchbrackets.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,25 @@
1414

1515
var Pos = CodeMirror.Pos;
1616

17-
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
17+
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"};
18+
19+
function bracketRegex(config) {
20+
return config && config.bracketRegex || /[(){}[\]]/
21+
}
1822

1923
function findMatchingBracket(cm, where, config) {
2024
var line = cm.getLineHandle(where.line), pos = where.ch - 1;
2125
var afterCursor = config && config.afterCursor
2226
if (afterCursor == null)
2327
afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
28+
var re = bracketRegex(config)
2429

2530
// A cursor is defined as between two characters, but in in vim command mode
2631
// (i.e. not insert mode), the cursor is visually represented as a
2732
// highlighted box on top of the 2nd character. Otherwise, we allow matches
2833
// from before or after the cursor.
29-
var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
30-
matching[line.text.charAt(++pos)];
34+
var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) ||
35+
re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)];
3136
if (!match) return null;
3237
var dir = match.charAt(1) == ">" ? 1 : -1;
3338
if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
@@ -51,7 +56,7 @@
5156
var maxScanLines = (config && config.maxScanLines) || 1000;
5257

5358
var stack = [];
54-
var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
59+
var re = bracketRegex(config)
5560
var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
5661
: Math.max(cm.firstLine() - 1, where.line - maxScanLines);
5762
for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {

codemirror/js/addon/hint/html-hint.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@
322322
itemtype: null,
323323
lang: ["en", "es"],
324324
spellcheck: ["true", "false"],
325+
autocorrect: ["true", "false"],
326+
autocapitalize: ["true", "false"],
325327
style: null,
326328
tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
327329
title: null,

codemirror/js/addon/hint/show-hint.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// CodeMirror, copyright (c) by Marijn Haverbeke and others
22
// Distributed under an MIT license: https://codemirror.net/LICENSE
33

4+
var mac = /Mac/.test(navigator.platform);
5+
46
(function(mod) {
57
if (typeof exports == "object" && typeof module == "object") // CommonJS
68
mod(require("../../lib/codemirror"));
@@ -46,6 +48,10 @@
4648
completion.update(true);
4749
});
4850

51+
CodeMirror.defineExtension("closeHint", function() {
52+
if (this.state.completionActive) this.state.completionActive.close()
53+
})
54+
4955
function Completion(cm, options) {
5056
this.cm = cm;
5157
this.options = options;
@@ -163,6 +169,12 @@
163169
Tab: handle.pick,
164170
Esc: handle.close
165171
};
172+
173+
if (mac) {
174+
baseMap["Ctrl-P"] = function() {handle.moveFocus(-1);};
175+
baseMap["Ctrl-N"] = function() {handle.moveFocus(1);};
176+
}
177+
166178
var custom = completion.options.customKeys;
167179
var ourMap = custom ? {} : baseMap;
168180
function addBinding(key, val) {
@@ -198,20 +210,22 @@
198210
this.data = data;
199211
this.picked = false;
200212
var widget = this, cm = completion.cm;
213+
var ownerDocument = cm.getInputField().ownerDocument;
214+
var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow;
201215

202-
var hints = this.hints = document.createElement("ul");
216+
var hints = this.hints = ownerDocument.createElement("ul");
203217
var theme = completion.cm.options.theme;
204218
hints.className = "CodeMirror-hints " + theme;
205219
this.selectedHint = data.selectedHint || 0;
206220

207221
var completions = data.list;
208222
for (var i = 0; i < completions.length; ++i) {
209-
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
223+
var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i];
210224
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
211225
if (cur.className != null) className = cur.className + " " + className;
212226
elt.className = className;
213227
if (cur.render) cur.render(elt, data, cur);
214-
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
228+
else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur)));
215229
elt.hintId = i;
216230
}
217231

@@ -220,9 +234,9 @@
220234
hints.style.left = left + "px";
221235
hints.style.top = top + "px";
222236
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
223-
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
224-
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
225-
(completion.options.container || document.body).appendChild(hints);
237+
var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth);
238+
var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight);
239+
(completion.options.container || ownerDocument.body).appendChild(hints);
226240
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
227241
var scrolls = hints.scrollHeight > hints.clientHeight + 1
228242
var startScroll = cm.getScrollInfo();
@@ -273,7 +287,7 @@
273287
cm.on("scroll", this.onScroll = function() {
274288
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
275289
var newTop = top + startScroll.top - curScroll.top;
276-
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
290+
var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop);
277291
if (!below) point += hints.offsetHeight;
278292
if (point <= editor.top || point >= editor.bottom) return completion.close();
279293
hints.style.top = newTop + "px";

codemirror/js/addon/mode/multiplex.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
5454
// Get the outer indent, making sure to handle CodeMirror.Pass
5555
var outerIndent = 0;
5656
if (outer.indent) {
57-
var possibleOuterIndent = outer.indent(state.outer, "");
57+
var possibleOuterIndent = outer.indent(state.outer, "", "");
5858
if (possibleOuterIndent !== CodeMirror.Pass) outerIndent = possibleOuterIndent;
5959
}
6060

@@ -96,10 +96,10 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
9696
}
9797
},
9898

99-
indent: function(state, textAfter) {
99+
indent: function(state, textAfter, line) {
100100
var mode = state.innerActive ? state.innerActive.mode : outer;
101101
if (!mode.indent) return CodeMirror.Pass;
102-
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
102+
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter, line);
103103
},
104104

105105
blankLine: function(state) {
@@ -112,7 +112,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
112112
var other = others[i];
113113
if (other.open === "\n") {
114114
state.innerActive = other;
115-
state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "") : 0);
115+
state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "", "") : 0);
116116
}
117117
}
118118
} else if (state.innerActive.close === "\n") {

codemirror/js/addon/mode/overlay.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
6868
else return state.overlayCur;
6969
},
7070

71-
indent: base.indent && function(state, textAfter) {
72-
return base.indent(state.base, textAfter);
71+
indent: base.indent && function(state, textAfter, line) {
72+
return base.indent(state.base, textAfter, line);
7373
},
7474
electricChars: base.electricChars,
7575

codemirror/js/codemirror.addons.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)