Skip to content

Commit ba23743

Browse files
committed
Merge remote-tracking branch 'codemirror/master'
2 parents 3c18350 + f5751d0 commit ba23743

File tree

115 files changed

+10111
-9558
lines changed

Some content is hidden

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

115 files changed

+10111
-9558
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
*.swp
77
.idea
88
*.iml
9+
/lib/codemirror.js

AUTHORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Brian Sletten
9898
Bruce Mitchener
9999
Caitlin Potter
100100
Calin Barbat
101+
callodacity
101102
Camilo Roca
102103
Chad Jolly
103104
Chandra Sekhar Pydi
@@ -180,6 +181,7 @@ feizhang365
180181
Felipe Lalanne
181182
Felix Raab
182183
Filip Noetzel
184+
Filip Stollár
183185
flack
184186
ForbesLindesay
185187
Forbes Lindesay
@@ -271,6 +273,7 @@ Jim
271273
JobJob
272274
jochenberger
273275
Jochen Berger
276+
Joel Einbinder
274277
joelpinheiro
275278
Johan Ask
276279
John Connor
@@ -402,6 +405,7 @@ Mike Brevoort
402405
Mike Diaz
403406
Mike Ivanov
404407
Mike Kadin
408+
Mike Kobit
405409
MinRK
406410
Miraculix87
407411
misfo
@@ -461,6 +465,7 @@ Philipp A
461465
Philip Stadermann
462466
Pierre Gerold
463467
Piët Delport
468+
Pontus Melke
464469
prasanthj
465470
Prasanth J
466471
Prayag Verma
@@ -474,6 +479,7 @@ Randy Edmunds
474479
Rasmus Erik Voel Jensen
475480
ray ratchup
476481
Ray Ratchup
482+
Remi Nyborg
477483
Richard Denton
478484
Richard van der Meer
479485
Richard Z.H. Wang
@@ -485,6 +491,7 @@ Rrandom
485491
Ruslan Osmanov
486492
Ryan Prior
487493
sabaca
494+
Sam Lee
488495
Samuel Ainsworth
489496
Sam Wilson
490497
sandeepshetty
@@ -542,6 +549,7 @@ thanasis
542549
TheHowl
543550
think
544551
Thomas Dvornik
552+
Thomas Kluyver
545553
Thomas Schmid
546554
Tim Alby
547555
Tim Baumann

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
1+
## 5.19.0 (2016-09-20)
2+
3+
### Bugfixes
4+
5+
[erlang mode](http://codemirror.net/mode/erlang): Fix mode crash when trying to read an empty context.
6+
7+
[comment addon](http://codemirror.net/doc/manual.html#addon_comment): Fix broken behavior when toggling comments inside a comment.
8+
9+
xml-fold addon: Fix a null-dereference bug.
10+
11+
Page up and page down now do something even in single-line documents.
12+
13+
Fix an issue where the cursor position could be off in really long (~8000 character) tokens.
14+
15+
### New features
16+
17+
[javascript mode](http://codemirror.net/mode/javascript): Better indentation when semicolons are missing. Better support for TypeScript classes, optional parameters, and the `type` keyword.
18+
19+
The [`blur`](http://codemirror.net/doc/manual.html#event_blur) and [`focus`](http://codemirror.net/doc/manual.html#event_focus) events now pass the DOM event to their handlers.
20+
21+
## 5.18.2 (2016-08-23)
22+
23+
### Bugfixes
24+
25+
[vue mode](http://codemirror.net/mode/vue): Fix outdated references to renamed Pug mode dependency.
26+
27+
## 5.18.0 (2016-08-22)
28+
29+
### Bugfixes
30+
31+
Make sure [gutter backgrounds](http://codemirror.net/doc/manual.html#addLineClass) stick to the rest of the gutter during horizontal scrolling.
32+
33+
The contenteditable [`inputStyle`](http://codemirror.net/doc/manual.html#option_inputStyle) now properly supports pasting on pre-Edge IE versions.
34+
35+
[javascript mode](http://codemirror.net/mode/javascript): Fix some small parsing bugs and improve TypeScript support.
36+
37+
[matchbrackets addon](http://codemirror.net/doc/manual.html#addon_matchbrackets): Fix bug where active highlighting was left in editor when the addon was disabled.
38+
39+
[match-highlighter addon](http://codemirror.net/doc/manual.html#addon_match-highlighter): Only start highlighting things when the editor gains focus.
40+
41+
[javascript-hint addon](http://codemirror.net/doc/manual.html#addon_javascript-hint): Also complete non-enumerable properties.
42+
43+
### New features
44+
45+
The [`addOverlay`](http://codemirror.net/doc/manual.html#addOverlay) method now supports a `priority` option to control the order in which overlays are applied.
46+
47+
MIME types that end in `+json` now default to the JSON mode when the MIME itself is not defined.
48+
49+
### Breaking changes
50+
51+
The mode formerly known as Jade was renamed to [Pug](http://codemirror.net/mode/pug).
52+
53+
The [Python mode](http://codemirror.net/mode/python) now defaults to Python 3 (rather than 2) syntax.
54+
155
## 5.17.0 (2016-07-19)
256

357
### Bugfixes

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;

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) {

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) {

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
}

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
}

bin/release

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rewrite("lib/codemirror.js", function(lib) {
2121
"CodeMirror.version = \"" + number + "\"");
2222
});
2323
function rewriteJSON(pack) {
24-
return pack.replace(/"version":"\d+\.\d+\.\d+"/, "\"version\":\"" + number + "\"");
24+
return pack.replace(/"version":\s*"\d+\.\d+\.\d+"/, "\"version\": \"" + number + "\"");
2525
}
2626
rewrite("package.json", rewriteJSON);
2727
rewrite("doc/manual.html", function(manual) {
@@ -32,11 +32,6 @@ if (bumpOnly) process.exit(0);
3232

3333
child.exec("bash bin/authors.sh", function(){});
3434

35-
rewrite("doc/compress.html", function(cmp) {
36-
return cmp.replace(/<option value="http:\/\/codemirror.net\/">HEAD<\/option>/,
37-
"<option value=\"http://codemirror.net/\">HEAD</option>\n <option value=\"http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=" + number + ";f=\">" + number + "</option>");
38-
});
39-
4035
rewrite("index.html", function(index) {
4136
return index.replace(/\.zip">\d+\.\d+\.\d+<\/a>/,
4237
".zip\">" + number + "</a>");

demo/lint.html

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
<script src="../mode/css/css.js"></script>
1212
<script src="//ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
1313
<script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
14+
<script src="http://csslint.net/js/csslint.js"></script>
1415
<script src="../addon/lint/lint.js"></script>
1516
<script src="../addon/lint/javascript-lint.js"></script>
1617
<script src="../addon/lint/json-lint.js"></script>
18+
<script src="../addon/lint/css-lint.js"></script>
1719
<style type="text/css">
1820
.CodeMirror {border: 1px solid black;}
1921
</style>
@@ -83,6 +85,66 @@ <h2>Linter Demo</h2>
8385
]
8486
</textarea></p>
8587

88+
<p><textarea id="code-css">@charset "UTF-8";
89+
90+
@import url("booya.css") print, screen;
91+
@import "whatup.css" screen;
92+
@import "wicked.css";
93+
94+
/*Error*/
95+
@charset "UTF-8";
96+
97+
98+
@namespace "http://www.w3.org/1999/xhtml";
99+
@namespace svg "http://www.w3.org/2000/svg";
100+
101+
/*Warning: empty ruleset */
102+
.foo {
103+
}
104+
105+
h1 {
106+
font-weight: bold;
107+
}
108+
109+
/*Warning: qualified heading */
110+
.foo h1 {
111+
font-weight: bold;
112+
}
113+
114+
/*Warning: adjoining classes */
115+
.foo.bar {
116+
zoom: 1;
117+
}
118+
119+
li.inline {
120+
width: 100%; /*Warning: 100% can be problematic*/
121+
}
122+
123+
li.last {
124+
display: inline;
125+
padding-left: 3px !important;
126+
padding-right: 3px;
127+
border-right: 0px;
128+
}
129+
130+
@media print {
131+
li.inline {
132+
color: black;
133+
}
134+
}
135+
136+
@page {
137+
margin: 10%;
138+
counter-increment: page;
139+
140+
@top-center {
141+
font-family: sans-serif;
142+
font-weight: bold;
143+
font-size: 2em;
144+
content: counter(page);
145+
}
146+
}
147+
</textarea></p>
86148
<script>
87149
var editor = CodeMirror.fromTextArea(document.getElementById("code-js"), {
88150
lineNumbers: true,
@@ -98,6 +160,12 @@ <h2>Linter Demo</h2>
98160
lint: true
99161
});
100162

163+
var editor_css = CodeMirror.fromTextArea(document.getElementById("code-css"), {
164+
lineNumbers: true,
165+
mode: "css",
166+
gutters: ["CodeMirror-lint-markers"],
167+
lint: true
168+
});
101169
</script>
102170

103171
</article>

0 commit comments

Comments
 (0)