(doc, pos, oldPos, dir, mayClear)
| 5159 | } |
| 5160 | |
| 5161 | function skipAtomicInner(doc, pos, oldPos, dir, mayClear) { |
| 5162 | var line = getLine(doc, pos.line); |
| 5163 | if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { |
| 5164 | var sp = line.markedSpans[i], m = sp.marker; |
| 5165 | |
| 5166 | // Determine if we should prevent the cursor being placed to the left/right of an atomic marker |
| 5167 | // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it |
| 5168 | // is with selectLeft/Right |
| 5169 | var preventCursorLeft = ("selectLeft" in m) ? !m.selectLeft : m.inclusiveLeft; |
| 5170 | var preventCursorRight = ("selectRight" in m) ? !m.selectRight : m.inclusiveRight; |
| 5171 | |
| 5172 | if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && |
| 5173 | (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) { |
| 5174 | if (mayClear) { |
| 5175 | signal(m, "beforeCursorEnter"); |
| 5176 | if (m.explicitlyCleared) { |
| 5177 | if (!line.markedSpans) { break } |
| 5178 | else {--i; continue} |
| 5179 | } |
| 5180 | } |
| 5181 | if (!m.atomic) { continue } |
| 5182 | |
| 5183 | if (oldPos) { |
| 5184 | var near = m.find(dir < 0 ? 1 : -1), diff = (void 0); |
| 5185 | if (dir < 0 ? preventCursorRight : preventCursorLeft) |
| 5186 | { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); } |
| 5187 | if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) |
| 5188 | { return skipAtomicInner(doc, near, pos, dir, mayClear) } |
| 5189 | } |
| 5190 | |
| 5191 | var far = m.find(dir < 0 ? -1 : 1); |
| 5192 | if (dir < 0 ? preventCursorLeft : preventCursorRight) |
| 5193 | { far = movePos(doc, far, dir, far.line == pos.line ? line : null); } |
| 5194 | return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null |
| 5195 | } |
| 5196 | } } |
| 5197 | return pos |
| 5198 | } |
| 5199 | |
| 5200 | // Ensure a given position is not inside an atomic range. |
| 5201 | function skipAtomic(doc, pos, oldPos, bias, mayClear) { |
no test coverage detected