MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / updateSelection

Function updateSelection

static/js/codemirror/codemirror.js:725–744  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

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) {

Callers 2

updateDisplayFunction · 0.85
endOperationFunction · 0.85

Calls 5

posEqFunction · 0.85
updateSelectionCursorFunction · 0.85
updateSelectionRangeFunction · 0.85
cursorCoordsFunction · 0.85
getRectFunction · 0.85

Tested by

no test coverage detected