MCPcopy Index your code
hub / github.com/csev/py4e / indent

Function indent

tools/pythonauto/static/codemirror/python.js:205–231  ·  view source on GitHub ↗
(stream, state, type)

Source from the content-addressed store, hash-verified

203 }
204
205 function indent(stream, state, type) {
206 type = type || 'py';
207 var indentUnit = 0;
208 if (type === 'py') {
209 if (state.scopes[0].type !== 'py') {
210 state.scopes[0].offset = stream.indentation();
211 return;
212 }
213 for (var i = 0; i < state.scopes.length; ++i) {
214 if (state.scopes[i].type === 'py') {
215 indentUnit = state.scopes[i].offset + conf.indentUnit;
216 break;
217 }
218 }
219 } else if (stream.match(/\s*($|#)/, false)) {
220 // An open paren/bracket/brace with only space or comments after it
221 // on the line will indent the next line a fixed amount, to make it
222 // easier to put arguments, list items, etc. on their own lines.
223 indentUnit = stream.indentation() + hangingIndent;
224 } else {
225 indentUnit = stream.column() + stream.current().length;
226 }
227 state.scopes.unshift({
228 offset: indentUnit,
229 type: type
230 });
231 }
232
233 function dedent(stream, state, type) {
234 type = type || 'py';

Callers 1

tokenLexerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected