MCPcopy
hub / github.com/pandao/editor.md / enterLocalMode

Function enterLocalMode

lib/codemirror/addon/mode/simple.js:167–181  ·  view source on GitHub ↗
(config, state, spec, token)

Source from the content-addressed store, hash-verified

165 }
166
167 function enterLocalMode(config, state, spec, token) {
168 var pers;
169 if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next)
170 if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p;
171 var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec);
172 var lState = pers ? pers.state : CodeMirror.startState(mode);
173 if (spec.persistent && !pers)
174 state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates};
175
176 state.localState = lState;
177 state.local = {mode: mode,
178 end: spec.end && toRegex(spec.end),
179 endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
180 endToken: token && token.join ? token[token.length - 1] : token};
181 }
182
183 function indexOf(val, arr) {
184 for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true;

Callers 1

tokenFunctionFunction · 0.85

Calls 2

toRegexFunction · 0.85
cmpFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…