MCPcopy
hub / github.com/csev/py4e / deleteNearSelection

Function deleteNearSelection

tools/pythonauto/static/codemirrorepl/codemirror.js:3671–3692  ·  view source on GitHub ↗
(cm, compute)

Source from the content-addressed store, hash-verified

3669 // Helper for deleting text near the selection(s), used to implement
3670 // backspace, delete, and similar functionality.
3671 function deleteNearSelection(cm, compute) {
3672 var ranges = cm.doc.sel.ranges, kill = [];
3673 // Build up a set of ranges to kill first, merging overlapping
3674 // ranges.
3675 for (var i = 0; i < ranges.length; i++) {
3676 var toKill = compute(ranges[i]);
3677 while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
3678 var replaced = kill.pop();
3679 if (cmp(replaced.from, toKill.from) < 0) {
3680 toKill.from = replaced.from;
3681 break;
3682 }
3683 }
3684 kill.push(toKill);
3685 }
3686 // Next, remove those actual ranges.
3687 runInOp(cm, function() {
3688 for (var i = kill.length - 1; i >= 0; i--)
3689 replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
3690 ensureCursorVisible(cm);
3691 });
3692 }
3693
3694 // Used for horizontal relative motion. Dir is -1 or 1 (left or
3695 // right), unit can be "char", "column" (like char, but doesn't

Callers 1

codemirror.jsFile · 0.85

Calls 5

cmpFunction · 0.85
ensureCursorVisibleFunction · 0.85
lstFunction · 0.70
runInOpFunction · 0.70
replaceRangeFunction · 0.70

Tested by

no test coverage detected