(doc, anchor, head, bias, checkAtomic)
| 2590 | // updateDoc, since they have to be expressed in the line |
| 2591 | // numbers before the update. |
| 2592 | function setSelection(doc, anchor, head, bias, checkAtomic) { |
| 2593 | if (!checkAtomic && hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) { |
| 2594 | var filtered = filterSelectionChange(doc, anchor, head); |
| 2595 | head = filtered.head; |
| 2596 | anchor = filtered.anchor; |
| 2597 | } |
| 2598 | |
| 2599 | var sel = doc.sel; |
| 2600 | sel.goalColumn = null; |
| 2601 | if (bias == null) bias = posLess(head, sel.head) ? -1 : 1; |
| 2602 | // Skip over atomic spans. |
| 2603 | if (checkAtomic || !posEq(anchor, sel.anchor)) |
| 2604 | anchor = skipAtomic(doc, anchor, bias, checkAtomic != "push"); |
| 2605 | if (checkAtomic || !posEq(head, sel.head)) |
| 2606 | head = skipAtomic(doc, head, bias, checkAtomic != "push"); |
| 2607 | |
| 2608 | if (posEq(sel.anchor, anchor) && posEq(sel.head, head)) return; |
| 2609 | |
| 2610 | sel.anchor = anchor; sel.head = head; |
| 2611 | var inv = posLess(head, anchor); |
| 2612 | sel.from = inv ? head : anchor; |
| 2613 | sel.to = inv ? anchor : head; |
| 2614 | |
| 2615 | if (doc.cm) |
| 2616 | doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = |
| 2617 | doc.cm.curOp.cursorActivity = true; |
| 2618 | |
| 2619 | signalLater(doc, "cursorActivity", doc); |
| 2620 | } |
| 2621 | |
| 2622 | function reCheckSelection(cm) { |
| 2623 | setSelection(cm.doc, cm.doc.sel.from, cm.doc.sel.to, null, "push"); |
no test coverage detected