MCPcopy
hub / github.com/witheve/Eve / skipAtomicInner

Function skipAtomicInner

src/codemirror.js:2247–2277  ·  view source on GitHub ↗
(doc, pos, oldPos, dir, mayClear)

Source from the content-addressed store, hash-verified

2245 }
2246
2247 function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
2248 var line = getLine(doc, pos.line);
2249 if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
2250 var sp = line.markedSpans[i], m = sp.marker;
2251 if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
2252 (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
2253 if (mayClear) {
2254 signal(m, "beforeCursorEnter");
2255 if (m.explicitlyCleared) {
2256 if (!line.markedSpans) break;
2257 else {--i; continue;}
2258 }
2259 }
2260 if (!m.atomic) continue;
2261
2262 if (oldPos) {
2263 var near = m.find(dir < 0 ? 1 : -1), diff;
2264 if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
2265 near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
2266 if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
2267 return skipAtomicInner(doc, near, pos, dir, mayClear);
2268 }
2269
2270 var far = m.find(dir < 0 ? -1 : 1);
2271 if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
2272 far = movePos(doc, far, dir, far.line == pos.line ? line : null);
2273 return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
2274 }
2275 }
2276 return pos;
2277 }
2278
2279 // Ensure a given position is not inside an atomic range.
2280 function skipAtomic(doc, pos, oldPos, bias, mayClear) {

Callers 1

skipAtomicFunction · 0.85

Calls 3

getLineFunction · 0.85
movePosFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected