Skip to content

Commit

Permalink
Use CodeMirror.startState helper when getting state for inner modes
Browse files Browse the repository at this point in the history
Closes #3994
  • Loading branch information
marijnh committed May 2, 2016
1 parent 5b84f3d commit b38eb3f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mode/ebnf/ebnf.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

if (bracesMode !== null && (state.braced || peek === "{")) {
if (state.localState === null)
state.localState = bracesMode.startState();
state.localState = CodeMirror.startState(bracesMode);

var token = bracesMode.token(stream, state.localState),
text = stream.current();
Expand Down
4 changes: 2 additions & 2 deletions mode/haml/haml.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
return {
// default to html mode
startState: function() {
var htmlState = htmlMode.startState();
var rubyState = rubyMode.startState();
var htmlState = CodeMirror.startState(htmlMode);
var rubyState = CodeMirror.startState(rubyMode);
return {
htmlState: htmlState,
rubyState: rubyState,
Expand Down
2 changes: 1 addition & 1 deletion mode/htmlmixed/htmlmixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

return {
startState: function () {
var state = htmlMode.startState();
var state = CodeMirror.startState(htmlMode);
return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
},

Expand Down
6 changes: 3 additions & 3 deletions mode/jade/jade.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CodeMirror.defineMode('jade', function (config) {
this.isInterpolating = false;
this.interpolationNesting = 0;

this.jsState = jsMode.startState();
this.jsState = CodeMirror.startState(jsMode);

this.restOfLine = '';

Expand Down Expand Up @@ -386,7 +386,7 @@ CodeMirror.defineMode('jade', function (config) {
if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) {
if (stream.peek() === '=' || stream.peek() === '!') {
state.inAttributeName = false;
state.jsState = jsMode.startState();
state.jsState = CodeMirror.startState(jsMode);
if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') {
state.attributeIsType = true;
} else {
Expand Down Expand Up @@ -492,7 +492,7 @@ CodeMirror.defineMode('jade', function (config) {
if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) {
if (state.innerMode) {
if (!state.innerState) {
state.innerState = state.innerMode.startState ? state.innerMode.startState(stream.indentation()) : {};
state.innerState = state.innerMode.startState ? CodeMirror.startState(state.innerMode, stream.indentation()) : {};
}
return stream.hideFirstChars(state.indentOf + 2, function () {
return state.innerMode.token(stream, state.innerState) || true;
Expand Down
2 changes: 1 addition & 1 deletion mode/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.fencedChars = match[1]
// try switching mode
state.localMode = getMode(match[2]);
if (state.localMode) state.localState = state.localMode.startState();
if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
state.f = state.block = local;
if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = -1
Expand Down
2 changes: 1 addition & 1 deletion mode/pegjs/pegjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ CodeMirror.defineMode("pegjs", function (config) {
return "comment";
} else if (state.braced || stream.peek() === '{') {
if (state.localState === null) {
state.localState = jsMode.startState();
state.localState = CodeMirror.startState(jsMode);
}
var token = jsMode.token(stream, state.localState);
var text = stream.current();
Expand Down
8 changes: 4 additions & 4 deletions mode/slim/slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
};
return function(stream, state) {
rubyState = state.rubyState;
state.rubyState = rubyMode.startState();
state.rubyState = CodeMirror.startState(rubyMode);
state.tokenize = runSplat;
return ruby(stream, state);
};
Expand Down Expand Up @@ -317,7 +317,7 @@

function startSubMode(mode, state) {
var subMode = getMode(mode);
var subState = subMode.startState && subMode.startState();
var subState = CodeMirror.startState(subMode);

state.subMode = subMode;
state.subState = subState;
Expand Down Expand Up @@ -507,8 +507,8 @@
var mode = {
// default to html mode
startState: function() {
var htmlState = htmlMode.startState();
var rubyState = rubyMode.startState();
var htmlState = CodeMirror.startState(htmlMode);
var rubyState = CodeMirror.startState(rubyMode);
return {
htmlState: htmlState,
rubyState: rubyState,
Expand Down

0 comments on commit b38eb3f

Please # to comment.