MCPcopy Create free account
hub / github.com/TruthHun/BookStack / indentFunction

Function indentFunction

static/editor.md/lib/codemirror/addon/mode/simple.js:187–212  ·  view source on GitHub ↗
(states, meta)

Source from the content-addressed store, hash-verified

185 }
186
187 function indentFunction(states, meta) {
188 return function(state, textAfter, line) {
189 if (state.local && state.local.mode.indent)
190 return state.local.mode.indent(state.localState, textAfter, line);
191 if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
192 return CodeMirror.Pass;
193
194 var pos = state.indent.length - 1, rules = states[state.state];
195 scan: for (;;) {
196 for (var i = 0; i < rules.length; i++) {
197 var rule = rules[i];
198 if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
199 var m = rule.regex.exec(textAfter);
200 if (m && m[0]) {
201 pos--;
202 if (rule.next || rule.push) rules = states[rule.next || rule.push];
203 textAfter = textAfter.slice(m[0].length);
204 continue scan;
205 }
206 }
207 }
208 break;
209 }
210 return pos < 0 ? 0 : state.indent[pos];
211 };
212 }
213});

Callers 1

simple.jsFile · 0.85

Calls 1

indexOfFunction · 0.70

Tested by

no test coverage detected