Skip to content

Commit 50f3e8a

Browse files
committed
---
yaml --- r: 6076 b: refs/heads/master c: a6d856c h: refs/heads/master v: v3
1 parent 3e29060 commit 50f3e8a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 59cc8636b72e944d22b065874646ad14d44010a9
2+
refs/heads/master: a6d856c57c7b61106d08dcc3444b0f394ff2c73e

trunk/doc/tutorial/lib/codemirror-rust.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,19 @@ CodeMirror.defineMode("rust", function() {
213213
if (content == "||") return cont(poplex, pushlex("}", "block"), block);
214214
}
215215
if (content == "mutable" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
216-
&& !cx.stream.match("::", false))) return pass(recliteral);
216+
&& !cx.stream.match("::", false)))
217+
return pass(record_of(expression));
217218
return pass(block);
218219
}
219-
function recliteral(type) {
220-
if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(recliteral);}
221-
if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(recliteral);}
222-
if (type == ":") return cont(expression, recliteral);
223-
if (type == "}") return cont();
224-
return cont(recliteral);
220+
function record_of(comb) {
221+
function ro(type) {
222+
if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(ro);}
223+
if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
224+
if (type == ":") return cont(comb, ro);
225+
if (type == "}") return cont();
226+
return cont(ro);
227+
}
228+
return ro;
225229
}
226230
function blockvars(type) {
227231
if (type == "name") {cx.marked = "def"; return cont(blockvars);}
@@ -230,7 +234,7 @@ CodeMirror.defineMode("rust", function() {
230234
}
231235

232236
function letdef1(type) {
233-
if (type == ";") return cont();
237+
if (type.match(/[\]\)\};]/)) return cont();
234238
if (content == "=") return cont(expression, letdef2);
235239
if (type == ",") return cont(letdef1);
236240
return pass(pattern, maybetype, letdef1);
@@ -295,6 +299,7 @@ CodeMirror.defineMode("rust", function() {
295299
if (type == "atom") return cont(rtypemaybeparam);
296300
if (type == "op" || type == "obj") return cont(rtype);
297301
if (type == "fn") return cont(fntype);
302+
if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex);
298303
return matchBrackets(type, rtype);
299304
}
300305
function rtypemaybeparam(type) {

0 commit comments

Comments
 (0)