(cm)
| 723 | // SELECTION / CURSOR |
| 724 | |
| 725 | function updateSelection(cm) { |
| 726 | var display = cm.display; |
| 727 | var collapsed = posEq(cm.doc.sel.from, cm.doc.sel.to); |
| 728 | if (collapsed || cm.options.showCursorWhenSelecting) |
| 729 | updateSelectionCursor(cm); |
| 730 | else |
| 731 | display.cursor.style.display = display.otherCursor.style.display = "none"; |
| 732 | if (!collapsed) |
| 733 | updateSelectionRange(cm); |
| 734 | else |
| 735 | display.selectionDiv.style.display = "none"; |
| 736 | |
| 737 | // Move the hidden textarea near the cursor to prevent scrolling artifacts |
| 738 | var headPos = cursorCoords(cm, cm.doc.sel.head, "div"); |
| 739 | var wrapOff = getRect(display.wrapper), lineOff = getRect(display.lineDiv); |
| 740 | display.inputDiv.style.top = Math.max(0, Math.min(display.wrapper.clientHeight - 10, |
| 741 | headPos.top + lineOff.top - wrapOff.top)) + "px"; |
| 742 | display.inputDiv.style.left = Math.max(0, Math.min(display.wrapper.clientWidth - 10, |
| 743 | headPos.left + lineOff.left - wrapOff.left)) + "px"; |
| 744 | } |
| 745 | |
| 746 | // No selection, plain cursor |
| 747 | function updateSelectionCursor(cm) { |
no test coverage detected