MCPcopy Create free account
hub / github.com/breck7/scroll / skipAtomicInner

Function skipAtomicInner

external/.scrollLibs.js:7015–7057  ·  view source on GitHub ↗
(doc, pos, oldPos, dir, mayClear)

Source from the content-addressed store, hash-verified

7013 }
7014
7015 function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
7016 var line = getLine(doc, pos.line)
7017 if (line.markedSpans) {
7018 for (var i = 0; i < line.markedSpans.length; ++i) {
7019 var sp = line.markedSpans[i],
7020 m = sp.marker
7021 if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
7022 if (mayClear) {
7023 signal(m, "beforeCursorEnter")
7024 if (m.explicitlyCleared) {
7025 if (!line.markedSpans) {
7026 break
7027 } else {
7028 --i
7029 continue
7030 }
7031 }
7032 }
7033 if (!m.atomic) {
7034 continue
7035 }
7036
7037 if (oldPos) {
7038 var near = m.find(dir < 0 ? 1 : -1),
7039 diff = void 0
7040 if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft) {
7041 near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null)
7042 }
7043 if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) {
7044 return skipAtomicInner(doc, near, pos, dir, mayClear)
7045 }
7046 }
7047
7048 var far = m.find(dir < 0 ? -1 : 1)
7049 if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight) {
7050 far = movePos(doc, far, dir, far.line == pos.line ? line : null)
7051 }
7052 return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
7053 }
7054 }
7055 }
7056 return pos
7057 }
7058
7059 // Ensure a given position is not inside an atomic range.
7060 function skipAtomic(doc, pos, oldPos, bias, mayClear) {

Callers 1

skipAtomicFunction · 0.85

Calls 5

getLineFunction · 0.85
signalFunction · 0.85
movePosFunction · 0.85
cmpFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected