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

Function skipAtomicInner

static/mergely/lib/codemirror.js:2242–2270  ·  view source on GitHub ↗
(doc, pos, oldPos, dir, mayClear)

Source from the content-addressed store, hash-verified

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

Callers 1

skipAtomicFunction · 0.85

Calls 3

movePosFunction · 0.85
getLineFunction · 0.70
cmpFunction · 0.50

Tested by

no test coverage detected