Skip to content

Commit fb70833

Browse files
committed
Update CodeMirror to version 5.15.3
1 parent 16d5e3e commit fb70833

41 files changed

Lines changed: 834 additions & 310 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

public/vendor/codemirror/addon/edit/closebrackets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
var ranges = cm.listSelections();
110110
var opening = pos % 2 == 0;
111111

112-
var type, next;
112+
var type;
113113
for (var i = 0; i < ranges.length; i++) {
114114
var range = ranges[i], cur = range.head, curType;
115115
var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));

public/vendor/codemirror/addon/fold/brace-fold.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
CodeMirror.registerHelper("fold", "brace", function(cm, start) {
1515
var line = start.line, lineText = cm.getLine(line);
16-
var startCh, tokenType;
16+
var tokenType;
1717

1818
function findOpening(openCh) {
1919
for (var at = start.ch, pass = 0;;) {
@@ -72,15 +72,15 @@ CodeMirror.registerHelper("fold", "import", function(cm, start) {
7272
}
7373
}
7474

75-
var start = start.line, has = hasImport(start), prev;
76-
if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
75+
var startLine = start.line, has = hasImport(startLine), prev;
76+
if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1))
7777
return null;
7878
for (var end = has.end;;) {
7979
var next = hasImport(end.line + 1);
8080
if (next == null) break;
8181
end = next.end;
8282
}
83-
return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
83+
return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end};
8484
});
8585

8686
CodeMirror.registerHelper("fold", "include", function(cm, start) {
@@ -91,14 +91,14 @@ CodeMirror.registerHelper("fold", "include", function(cm, start) {
9191
if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
9292
}
9393

94-
var start = start.line, has = hasInclude(start);
95-
if (has == null || hasInclude(start - 1) != null) return null;
96-
for (var end = start;;) {
94+
var startLine = start.line, has = hasInclude(startLine);
95+
if (has == null || hasInclude(startLine - 1) != null) return null;
96+
for (var end = startLine;;) {
9797
var next = hasInclude(end + 1);
9898
if (next == null) break;
9999
++end;
100100
}
101-
return {from: CodeMirror.Pos(start, has + 1),
101+
return {from: CodeMirror.Pos(startLine, has + 1),
102102
to: cm.clipPos(CodeMirror.Pos(end))};
103103
});
104104

public/vendor/codemirror/addon/fold/xml-fold.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@
140140
var openTag = toNextTag(iter), end;
141141
if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
142142
if (!openTag[1] && end != "selfClose") {
143-
var start = Pos(iter.line, iter.ch);
144-
var close = findMatchingClose(iter, openTag[2]);
145-
return close && {from: start, to: close.from};
143+
var startPos = Pos(iter.line, iter.ch);
144+
var endPos = findMatchingClose(iter, openTag[2]);
145+
return endPos && {from: startPos, to: endPos.from};
146146
}
147147
}
148148
});

public/vendor/codemirror/addon/hint/show-hint.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
background: white;
1717
font-size: 90%;
1818
font-family: monospace;
19+
max-width: 19em;
1920

2021
max-height: 20em;
2122
overflow-y: auto;
@@ -25,8 +26,6 @@
2526
margin: 0;
2627
padding: 0 4px;
2728
border-radius: 2px;
28-
max-width: 19em;
29-
overflow: hidden;
3029
white-space: pre;
3130
color: black;
3231
cursor: pointer;

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

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,11 @@
108108
},
109109

110110
update: function(first) {
111-
if (this.tick == null) return;
112-
if (!this.options.hint.async) {
113-
this.finishUpdate(this.options.hint(this.cm, this.options), first);
114-
} else {
115-
var myTick = ++this.tick, self = this;
116-
this.options.hint(this.cm, function(data) {
117-
if (self.tick == myTick) self.finishUpdate(data, first);
118-
}, this.options);
119-
}
111+
if (this.tick == null) return
112+
var self = this, myTick = ++this.tick
113+
fetchHints(this.options.hint, this.cm, this.options, function(data) {
114+
if (self.tick == myTick) self.finishUpdate(data, first)
115+
})
120116
},
121117

122118
finishUpdate: function(data, first) {
@@ -233,6 +229,7 @@
233229
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
234230
(completion.options.container || document.body).appendChild(hints);
235231
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
232+
var scrolls = hints.scrollHeight > hints.clientHeight + 1
236233
if (overlapY > 0) {
237234
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
238235
if (curTop - height > 0) { // Fits above cursor
@@ -257,6 +254,8 @@
257254
}
258255
hints.style.left = (left = pos.left - overlapX) + "px";
259256
}
257+
if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
258+
node.style.paddingRight = cm.display.nativeBarWidth + "px"
260259

261260
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
262261
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
@@ -362,40 +361,31 @@
362361
return result
363362
}
364363

364+
function fetchHints(hint, cm, options, callback) {
365+
if (hint.async) {
366+
hint(cm, callback, options)
367+
} else {
368+
var result = hint(cm, options)
369+
if (result && result.then) result.then(callback)
370+
else callback(result)
371+
}
372+
}
373+
365374
function resolveAutoHints(cm, pos) {
366375
var helpers = cm.getHelpers(pos, "hint"), words
367376
if (helpers.length) {
368-
var async = false, resolved
369-
for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true
370-
if (async) {
371-
resolved = function(cm, callback, options) {
372-
var app = applicableHelpers(cm, helpers)
373-
function run(i, result) {
374-
if (i == app.length) return callback(null)
375-
var helper = app[i]
376-
if (helper.async) {
377-
helper(cm, function(result) {
378-
if (result) callback(result)
379-
else run(i + 1)
380-
}, options)
381-
} else {
382-
var result = helper(cm, options)
383-
if (result) callback(result)
384-
else run(i + 1)
385-
}
386-
}
387-
run(0)
388-
}
389-
resolved.async = true
390-
} else {
391-
resolved = function(cm, options) {
392-
var app = applicableHelpers(cm, helpers)
393-
for (var i = 0; i < app.length; i++) {
394-
var cur = app[i](cm, options)
395-
if (cur && cur.list.length) return cur
396-
}
377+
var resolved = function(cm, callback, options) {
378+
var app = applicableHelpers(cm, helpers);
379+
function run(i) {
380+
if (i == app.length) return callback(null)
381+
fetchHints(app[i], cm, options, function(result) {
382+
if (result && result.list.length > 0) callback(result)
383+
else run(i + 1)
384+
})
397385
}
386+
run(0)
398387
}
388+
resolved.async = true
399389
resolved.supportsSelection = true
400390
return resolved
401391
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {

public/vendor/codemirror/addon/hint/sql-hint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
var defaultTableName = options && options.defaultTable;
242242
var disableKeywords = options && options.disableKeywords;
243243
defaultTable = defaultTableName && getTable(defaultTableName);
244-
keywords = keywords || getKeywords(editor);
244+
keywords = getKeywords(editor);
245245

246246
if (defaultTableName && !defaultTable)
247247
defaultTable = findTableByAlias(defaultTableName, editor);

public/vendor/codemirror/addon/lint/lint.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
}
55

66
.CodeMirror-lint-tooltip {
7-
background-color: infobackground;
7+
background-color: #ffd;
88
border: 1px solid black;
99
border-radius: 4px 4px 4px 4px;
10-
color: infotext;
10+
color: black;
1111
font-family: monospace;
1212
font-size: 10pt;
1313
overflow: hidden;

public/vendor/codemirror/addon/lint/lint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@
204204

205205
var annotations = [];
206206
for (var i = 0; i < spans.length; ++i) {
207-
annotations.push(spans[i].__annotation);
207+
var ann = spans[i].__annotation;
208+
if (ann) annotations.push(ann);
208209
}
209210
if (annotations.length) popupTooltips(annotations, e);
210211
}

public/vendor/codemirror/addon/scroll/simplescrollbars.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
6060
}
6161

62-
Bar.prototype.setPos = function(pos) {
62+
Bar.prototype.setPos = function(pos, force) {
6363
if (pos < 0) pos = 0;
6464
if (pos > this.total - this.screen) pos = this.total - this.screen;
65-
if (pos == this.pos) return false;
65+
if (!force && pos == this.pos) return false;
6666
this.pos = pos;
6767
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
6868
(pos * (this.size / this.total)) + "px";
@@ -76,9 +76,12 @@
7676
var minButtonSize = 10;
7777

7878
Bar.prototype.update = function(scrollSize, clientSize, barSize) {
79-
this.screen = clientSize;
80-
this.total = scrollSize;
81-
this.size = barSize;
79+
var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize
80+
if (sizeChanged) {
81+
this.screen = clientSize;
82+
this.total = scrollSize;
83+
this.size = barSize;
84+
}
8285

8386
var buttonSize = this.screen * (this.size / this.total);
8487
if (buttonSize < minButtonSize) {
@@ -87,7 +90,7 @@
8790
}
8891
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
8992
buttonSize + "px";
90-
this.setPos(this.pos);
93+
this.setPos(this.pos, sizeChanged);
9194
};
9295

9396
function SimpleScrollbars(cls, place, scroll) {

public/vendor/codemirror/addon/search/match-highlighter.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,20 @@
2929
})(function(CodeMirror) {
3030
"use strict";
3131

32-
var DEFAULT_MIN_CHARS = 2;
33-
var DEFAULT_TOKEN_STYLE = "matchhighlight";
34-
var DEFAULT_DELAY = 100;
35-
var DEFAULT_WORDS_ONLY = false;
32+
var defaults = {
33+
style: "matchhighlight",
34+
minChars: 2,
35+
delay: 100,
36+
wordsOnly: false,
37+
annotateScrollbar: false,
38+
showToken: false,
39+
trim: true
40+
}
3641

3742
function State(options) {
38-
if (typeof options == "object") {
39-
this.minChars = options.minChars;
40-
this.style = options.style;
41-
this.showToken = options.showToken;
42-
this.delay = options.delay;
43-
this.wordsOnly = options.wordsOnly;
44-
this.annotateScrollbar = options.annotateScrollbar;
45-
}
46-
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
47-
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
48-
if (this.delay == null) this.delay = DEFAULT_DELAY;
49-
if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;
43+
this.options = {}
44+
for (var name in defaults)
45+
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
5046
this.overlay = this.timeout = null;
5147
this.matchesonscroll = null;
5248
}
@@ -68,13 +64,13 @@
6864
function cursorActivity(cm) {
6965
var state = cm.state.matchHighlighter;
7066
clearTimeout(state.timeout);
71-
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
67+
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
7268
}
7369

7470
function addOverlay(cm, query, hasBoundary, style) {
7571
var state = cm.state.matchHighlighter;
7672
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
77-
if (state.annotateScrollbar) {
73+
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
7874
var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
7975
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, true,
8076
{className: "CodeMirror-selection-highlight-scrollbar"});
@@ -86,7 +82,7 @@
8682
if (state.overlay) {
8783
cm.removeOverlay(state.overlay);
8884
state.overlay = null;
89-
if (state.annotateScrollbar) {
85+
if (state.matchesonscroll) {
9086
state.matchesonscroll.clear();
9187
state.matchesonscroll = null;
9288
}
@@ -97,21 +93,22 @@
9793
cm.operation(function() {
9894
var state = cm.state.matchHighlighter;
9995
removeOverlay(cm);
100-
if (!cm.somethingSelected() && state.showToken) {
101-
var re = state.showToken === true ? /[\w$]/ : state.showToken;
96+
if (!cm.somethingSelected() && state.options.showToken) {
97+
var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
10298
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
10399
while (start && re.test(line.charAt(start - 1))) --start;
104100
while (end < line.length && re.test(line.charAt(end))) ++end;
105101
if (start < end)
106-
addOverlay(cm, line.slice(start, end), re, state.style);
102+
addOverlay(cm, line.slice(start, end), re, state.options.style);
107103
return;
108104
}
109105
var from = cm.getCursor("from"), to = cm.getCursor("to");
110106
if (from.line != to.line) return;
111-
if (state.wordsOnly && !isWord(cm, from, to)) return;
112-
var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
113-
if (selection.length >= state.minChars)
114-
addOverlay(cm, selection, false, state.style);
107+
if (state.options.wordsOnly && !isWord(cm, from, to)) return;
108+
var selection = cm.getRange(from, to)
109+
if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "")
110+
if (selection.length >= state.options.minChars)
111+
addOverlay(cm, selection, false, state.options.style);
115112
});
116113
}
117114

0 commit comments

Comments
 (0)