Skip to content

Commit 736ec21

Browse files
qgustavormarijnh
authored andcommitted
[livescript mode] Fix string and comment highlighting
Only change `state.next` if `r.next` is defined, check if `r.regex` is a String before converting it into a RegExp (in the optimization step). Closes #2474.
1 parent 6c22112 commit 736ec21

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mode/livescript/livescript.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
for (i$ = 0, len$ = nr.length; i$ < len$; ++i$) {
2525
r = nr[i$];
2626
if (r.regex && (m = stream.match(r.regex))) {
27-
state.next = r.next;
27+
state.next = r.next || state.next;
2828
return r.token;
2929
}
3030
}
@@ -203,7 +203,7 @@
203203
next: 'start'
204204
}, {
205205
token: 'text',
206-
regex: '.',
206+
regex: '',
207207
next: 'start'
208208
}
209209
],
@@ -265,11 +265,11 @@
265265
if (Array.isArray(r)) {
266266
for (var i = 0, len = r.length; i < len; ++i) {
267267
var rr = r[i];
268-
if (rr.regex) {
268+
if (typeof rr.regex === 'string') {
269269
Rules[idx][i].regex = new RegExp('^' + rr.regex);
270270
}
271271
}
272-
} else if (r.regex) {
272+
} else if (typeof rr.regex === 'string') {
273273
Rules[idx].regex = new RegExp('^' + r.regex);
274274
}
275275
}

0 commit comments

Comments
 (0)