Skip to content

Commit c423228

Browse files
committed
[javascript mode] Fix expressionAllowed to return false when not in base tokenizer
Issue #4908
1 parent 404d869 commit c423228

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

mode/javascript/javascript.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
})(function(CodeMirror) {
1212
"use strict";
1313

14-
function expressionAllowed(stream, state, backUp) {
15-
return /^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
16-
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
17-
}
18-
1914
CodeMirror.defineMode("javascript", function(config, parserConfig) {
2015
var indentUnit = config.indentUnit;
2116
var statementIndent = parserConfig.statementIndent;
@@ -733,6 +728,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
733728
/[,.]/.test(textAfter.charAt(0));
734729
}
735730

731+
function expressionAllowed(stream, state, backUp) {
732+
return state.tokenize == tokenBase &&
733+
/^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
734+
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
735+
}
736+
736737
// Interface
737738

738739
return {
@@ -807,6 +808,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
807808
jsonMode: jsonMode,
808809

809810
expressionAllowed: expressionAllowed,
811+
810812
skipExpression: function(state) {
811813
var top = state.cc[state.cc.length - 1]
812814
if (top == expression || top == expressionNoComma) state.cc.pop()

0 commit comments

Comments
 (0)