Skip to content

Commit 795ea21

Browse files
committed
Update CodeMirror to 5.19.0 and rename jade to pug
1 parent fb5d7e4 commit 795ea21

30 files changed

Lines changed: 341 additions & 209 deletions

public/js/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ var cursorMenuThrottle = 50;
144144
var cursorActivityDebounce = 50;
145145
var cursorAnimatePeriod = 100;
146146
var supportContainers = ['success', 'info', 'warning', 'danger'];
147-
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
147+
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
148148
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid'];
149149
var supportHeaders = [
150150
{

public/vendor/codemirror/addon/comment/comment.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
self.lineComment(from, to, options);
104104
return;
105105
}
106+
if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
106107

107108
var end = Math.min(to.line, self.lastLine());
108109
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
@@ -140,7 +141,7 @@
140141
var line = self.getLine(i);
141142
var found = line.indexOf(lineString);
142143
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
143-
if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
144+
if (found == -1 && nonWS.test(line)) break lineComment;
144145
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
145146
lines.push(line);
146147
}
@@ -162,13 +163,15 @@
162163
var endString = options.blockCommentEnd || mode.blockCommentEnd;
163164
if (!startString || !endString) return false;
164165
var lead = options.blockCommentLead || mode.blockCommentLead;
165-
var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
166-
var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
166+
var startLine = self.getLine(start), open = startLine.indexOf(startString)
167+
if (open == -1) return false
168+
var endLine = end == start ? startLine : self.getLine(end)
169+
var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
167170
if (close == -1 && start != end) {
168171
endLine = self.getLine(--end);
169-
close = endLine.lastIndexOf(endString);
172+
close = endLine.indexOf(endString);
170173
}
171-
if (open == -1 || close == -1 ||
174+
if (close == -1 ||
172175
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
173176
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
174177
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
function Iter(cm, line, ch, range) {
2222
this.line = line; this.ch = ch;
2323
this.cm = cm; this.text = cm.getLine(line);
24-
this.min = range ? range.from : cm.firstLine();
25-
this.max = range ? range.to - 1 : cm.lastLine();
24+
this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
25+
this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
2626
}
2727

2828
function tagAt(iter, ch) {

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@
9797
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
9898
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
9999

100+
function forAllProps(obj, callback) {
101+
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
102+
for (var name in obj) callback(name)
103+
} else {
104+
for (var o = obj; o; o = Object.getPrototypeOf(o))
105+
Object.getOwnPropertyNames(o).forEach(callback)
106+
}
107+
}
108+
100109
function getCompletions(token, context, keywords, options) {
101110
var found = [], start = token.string, global = options && options.globalScope || window;
102111
function maybeAdd(str) {
@@ -106,7 +115,7 @@
106115
if (typeof obj == "string") forEach(stringProps, maybeAdd);
107116
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
108117
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
109-
for (var name in obj) maybeAdd(name);
118+
forAllProps(obj, maybeAdd)
110119
}
111120

112121
if (context && context.length) {

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
4646
this.overlay = this.timeout = null;
4747
this.matchesonscroll = null;
48+
this.active = false;
4849
}
4950

5051
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
@@ -53,16 +54,34 @@
5354
clearTimeout(cm.state.matchHighlighter.timeout);
5455
cm.state.matchHighlighter = null;
5556
cm.off("cursorActivity", cursorActivity);
57+
cm.off("focus", onFocus)
5658
}
5759
if (val) {
58-
cm.state.matchHighlighter = new State(val);
59-
highlightMatches(cm);
60+
var state = cm.state.matchHighlighter = new State(val);
61+
if (cm.hasFocus()) {
62+
state.active = true
63+
highlightMatches(cm)
64+
} else {
65+
cm.on("focus", onFocus)
66+
}
6067
cm.on("cursorActivity", cursorActivity);
6168
}
6269
});
6370

6471
function cursorActivity(cm) {
6572
var state = cm.state.matchHighlighter;
73+
if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
74+
}
75+
76+
function onFocus(cm) {
77+
var state = cm.state.matchHighlighter
78+
if (!state.active) {
79+
state.active = true
80+
scheduleHighlight(cm, state)
81+
}
82+
}
83+
84+
function scheduleHighlight(cm, state) {
6685
clearTimeout(state.timeout);
6786
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
6887
}

public/vendor/codemirror/addon/search/search.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,11 @@
136136
})
137137
};
138138
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
139-
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][CodeMirror.keyName(event)];
140-
if (cmd == "findNext" || cmd == "findPrev") {
139+
var keyName = CodeMirror.keyName(event)
140+
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
141+
if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
142+
if (cmd == "findNext" || cmd == "findPrev" ||
143+
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
141144
CodeMirror.e_stop(event);
142145
startSearch(cm, getSearchState(cm), query);
143146
cm.execCommand(cmd);
@@ -146,7 +149,7 @@
146149
searchNext(query, event);
147150
}
148151
});
149-
if (immediate) {
152+
if (immediate && q) {
150153
startSearch(cm, state, q);
151154
findNext(cm, rev);
152155
}

public/vendor/codemirror/codemirror.min.js

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

public/vendor/codemirror/compress.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ addon/fold/foldgutter.js \
3030
addon/fold/markdown-fold.js \
3131
addon/fold/xml-fold.js \
3232
mode/xml/xml.js \
33-
mode/markdown/markdown.js \
33+
mode/markdown/markdown_math.js \
3434
mode/gfm/gfm.js \
3535
mode/javascript/javascript.js \
3636
mode/css/css.js \
@@ -45,7 +45,7 @@ mode/php/php.js \
4545
mode/sql/sql.js \
4646
mode/coffeescript/coffeescript.js \
4747
mode/yaml/yaml.js \
48-
mode/jade/jade.js \
48+
mode/pug/pug.js \
4949
mode/lua/lua.js \
5050
mode/cmake/cmake.js \
5151
mode/nginx/nginx.js \

public/vendor/codemirror/keymap/vim.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,12 @@
780780

781781
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
782782
if (keysAreChars) {
783-
var here = cm.getCursor();
784-
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
783+
var selections = cm.listSelections();
784+
for (var i = 0; i < selections.length; i++) {
785+
var here = selections[i].head;
786+
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
787+
}
788+
vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
785789
}
786790
clearInputState(cm);
787791
return match.command;
@@ -818,7 +822,7 @@
818822
// TODO: Look into using CodeMirror's multi-key handling.
819823
// Return no-op since we are caching the key. Counts as handled, but
820824
// don't want act on it just yet.
821-
return function() {};
825+
return function() { return true; };
822826
} else {
823827
return function() {
824828
return cm.operation(function() {
@@ -4874,6 +4878,10 @@
48744878
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
48754879
|| changeObj.origin === undefined /* only in testing */) {
48764880
var text = changeObj.text.join('\n');
4881+
if (lastChange.maybeReset) {
4882+
lastChange.changes = [];
4883+
lastChange.maybeReset = false;
4884+
}
48774885
lastChange.changes.push(text);
48784886
}
48794887
// Change objects may be chained with next.
@@ -4896,7 +4904,7 @@
48964904
lastChange.expectCursorActivityForChange = false;
48974905
} else {
48984906
// Cursor moved outside the context of an edit. Reset the change.
4899-
lastChange.changes = [];
4907+
lastChange.maybeReset = true;
49004908
}
49014909
} else if (!cm.curOp.isVimOp) {
49024910
handleExternalSelection(cm, vim);
@@ -4960,6 +4968,10 @@
49604968
var keyName = CodeMirror.keyName(e);
49614969
if (!keyName) { return; }
49624970
function onKeyFound() {
4971+
if (lastChange.maybeReset) {
4972+
lastChange.changes = [];
4973+
lastChange.maybeReset = false;
4974+
}
49634975
lastChange.changes.push(new InsertModeKey(keyName));
49644976
return true;
49654977
}

0 commit comments

Comments
 (0)