Skip to content

Commit 0e80400

Browse files
committed
Make sure indent is always passed three arguments
Closes codemirror/google-modes#235
1 parent 12f8159 commit 0e80400

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

addon/mode/multiplex.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
5454
// Get the outer indent, making sure to handle CodeMirror.Pass
5555
var outerIndent = 0;
5656
if (outer.indent) {
57-
var possibleOuterIndent = outer.indent(state.outer, "");
57+
var possibleOuterIndent = outer.indent(state.outer, "", "");
5858
if (possibleOuterIndent !== CodeMirror.Pass) outerIndent = possibleOuterIndent;
5959
}
6060

@@ -96,10 +96,10 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
9696
}
9797
},
9898

99-
indent: function(state, textAfter) {
99+
indent: function(state, textAfter, line) {
100100
var mode = state.innerActive ? state.innerActive.mode : outer;
101101
if (!mode.indent) return CodeMirror.Pass;
102-
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
102+
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter, line);
103103
},
104104

105105
blankLine: function(state) {
@@ -112,7 +112,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
112112
var other = others[i];
113113
if (other.open === "\n") {
114114
state.innerActive = other;
115-
state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "") : 0);
115+
state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "", "") : 0);
116116
}
117117
}
118118
} else if (state.innerActive.close === "\n") {

addon/mode/overlay.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
6868
else return state.overlayCur;
6969
},
7070

71-
indent: base.indent && function(state, textAfter) {
72-
return base.indent(state.base, textAfter);
71+
indent: base.indent && function(state, textAfter, line) {
72+
return base.indent(state.base, textAfter, line);
7373
},
7474
electricChars: base.electricChars,
7575

mode/htmlmixed/htmlmixed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
106106
};
107107
state.localMode = mode;
108-
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
108+
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", ""));
109109
} else if (state.inTag) {
110110
state.inTag += stream.current()
111111
if (stream.eol()) state.inTag += " "
@@ -135,7 +135,7 @@
135135

136136
indent: function (state, textAfter, line) {
137137
if (!state.localMode || /^\s*<\//.test(textAfter))
138-
return htmlMode.indent(state.htmlState, textAfter);
138+
return htmlMode.indent(state.htmlState, textAfter, line);
139139
else if (state.localMode.indent)
140140
return state.localMode.indent(state.localState, textAfter, line);
141141
else

mode/jsx/jsx.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
function flatXMLIndent(state) {
3333
var tagName = state.tagName
3434
state.tagName = null
35-
var result = xmlMode.indent(state, "")
35+
var result = xmlMode.indent(state, "", "")
3636
state.tagName = tagName
3737
return result
3838
}
@@ -105,7 +105,7 @@
105105
function jsToken(stream, state, cx) {
106106
if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) {
107107
jsMode.skipExpression(cx.state)
108-
state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")),
108+
state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")),
109109
xmlMode, 0, state.context)
110110
return null
111111
}

mode/php/php.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
if (!isPHP) {
161161
if (stream.match(/^<\?\w*/)) {
162162
state.curMode = phpMode;
163-
if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, ""))
163+
if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "", ""))
164164
state.curState = state.php;
165165
return "meta";
166166
}
@@ -213,11 +213,11 @@
213213

214214
token: dispatch,
215215

216-
indent: function(state, textAfter) {
216+
indent: function(state, textAfter, line) {
217217
if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
218218
(state.curMode == phpMode && /^\?>/.test(textAfter)))
219-
return htmlMode.indent(state.html, textAfter);
220-
return state.curMode.indent(state.curState, textAfter);
219+
return htmlMode.indent(state.html, textAfter, line);
220+
return state.curMode.indent(state.curState, textAfter, line);
221221
},
222222

223223
blockCommentStart: "/*",

mode/smarty/smarty.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@
210210
state.last = last;
211211
return style;
212212
},
213-
indent: function(state, text) {
213+
indent: function(state, text, line) {
214214
if (state.tokenize == tokenTop && baseMode.indent)
215-
return baseMode.indent(state.base, text);
215+
return baseMode.indent(state.base, text, line);
216216
else
217217
return CodeMirror.Pass;
218218
},

mode/soy/soy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
var mode = modes[kind] || modes.html;
252252
var localState = last(state.localStates);
253253
if (localState.mode.indent) {
254-
state.indent += localState.mode.indent(localState.state, "");
254+
state.indent += localState.mode.indent(localState.state, "", "");
255255
}
256256
state.localStates.push({
257257
mode: mode,
@@ -310,7 +310,7 @@
310310
state.localStates.pop();
311311
var localState = last(state.localStates);
312312
if (localState.mode.indent) {
313-
state.indent -= localState.mode.indent(localState.state, "");
313+
state.indent -= localState.mode.indent(localState.state, "", "");
314314
}
315315
}
316316
state.soyState.push("tag");
@@ -346,7 +346,7 @@
346346
return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/);
347347
},
348348

349-
indent: function(state, textAfter) {
349+
indent: function(state, textAfter, line) {
350350
var indent = state.indent, top = last(state.soyState);
351351
if (top == "comment") return CodeMirror.Pass;
352352

@@ -360,7 +360,7 @@
360360
}
361361
var localState = last(state.localStates);
362362
if (indent && localState.mode.indent) {
363-
indent += localState.mode.indent(localState.state, textAfter);
363+
indent += localState.mode.indent(localState.state, textAfter, line);
364364
}
365365
return indent;
366366
},

test/mode_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
var line = lines[i], newLine = true;
124124
if (mode.indent) {
125125
var ws = line.match(/^\s*/)[0];
126-
var indent = mode.indent(state, line.slice(ws.length));
126+
var indent = mode.indent(state, line.slice(ws.length), line);
127127
if (indent != CodeMirror.Pass && indent != ws.length)
128128
(st.indentFailures || (st.indentFailures = [])).push(
129129
"Indentation of line " + (i + 1) + " is " + indent + " (expected " + ws.length + ")");

0 commit comments

Comments
 (0)