Skip to content

Commit 76bcde3

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 edad852 commit 76bcde3

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
@@ -13,7 +13,7 @@
1313
for (i$ = 0, len$ = nr.length; i$ < len$; ++i$) {
1414
r = nr[i$];
1515
if (r.regex && (m = stream.match(r.regex))) {
16-
state.next = r.next;
16+
state.next = r.next || state.next;
1717
return r.token;
1818
}
1919
}
@@ -192,7 +192,7 @@
192192
next: 'start'
193193
}, {
194194
token: 'text',
195-
regex: '.',
195+
regex: '',
196196
next: 'start'
197197
}
198198
],
@@ -254,11 +254,11 @@
254254
if (Array.isArray(r)) {
255255
for (var i = 0, len = r.length; i < len; ++i) {
256256
var rr = r[i];
257-
if (rr.regex) {
257+
if (typeof rr.regex === 'string') {
258258
Rules[idx][i].regex = new RegExp('^' + rr.regex);
259259
}
260260
}
261-
} else if (r.regex) {
261+
} else if (typeof rr.regex === 'string') {
262262
Rules[idx].regex = new RegExp('^' + r.regex);
263263
}
264264
}

0 commit comments

Comments
 (0)