MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / dedent

Function dedent

static/js/codemirror/mode/python/python.js:214–245  ·  view source on GitHub ↗
(stream, state, type)

Source from the content-addressed store, hash-verified

212 }
213
214 function dedent(stream, state, type) {
215 type = type || 'py';
216 if (state.scopes.length == 1) return;
217 if (state.scopes[0].type === 'py') {
218 var _indent = stream.indentation();
219 var _indent_index = -1;
220 for (var i = 0; i < state.scopes.length; ++i) {
221 if (_indent === state.scopes[i].offset) {
222 _indent_index = i;
223 break;
224 }
225 }
226 if (_indent_index === -1) {
227 return true;
228 }
229 while (state.scopes[0].offset !== _indent) {
230 state.scopes.shift();
231 }
232 return false;
233 } else {
234 if (type === 'py') {
235 state.scopes[0].offset = stream.indentation();
236 return false;
237 } else {
238 if (state.scopes[0].type != type) {
239 return true;
240 }
241 state.scopes.shift();
242 return false;
243 }
244 }
245 }
246
247 function tokenLexer(stream, state) {
248 indentInfo = null;

Callers 2

tokenBaseFunction · 0.70
tokenLexerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected