|
11 | 11 | })(function(CodeMirror) { |
12 | 12 | "use strict"; |
13 | 13 |
|
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 | | - |
19 | 14 | CodeMirror.defineMode("javascript", function(config, parserConfig) { |
20 | 15 | var indentUnit = config.indentUnit; |
21 | 16 | var statementIndent = parserConfig.statementIndent; |
@@ -733,6 +728,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { |
733 | 728 | /[,.]/.test(textAfter.charAt(0)); |
734 | 729 | } |
735 | 730 |
|
| 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 | + |
736 | 737 | // Interface |
737 | 738 |
|
738 | 739 | return { |
@@ -807,6 +808,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { |
807 | 808 | jsonMode: jsonMode, |
808 | 809 |
|
809 | 810 | expressionAllowed: expressionAllowed, |
| 811 | + |
810 | 812 | skipExpression: function(state) { |
811 | 813 | var top = state.cc[state.cc.length - 1] |
812 | 814 | if (top == expression || top == expressionNoComma) state.cc.pop() |
|
0 commit comments