MCPcopy Index your code
hub / github.com/DHTMLX/gantt / deleteNearSelection

Function deleteNearSelection

samples/common/codehighlight/codemirror.js:6809–6830  ·  view source on GitHub ↗
(cm, compute)

Source from the content-addressed store, hash-verified

6807 // Helper for deleting text near the selection(s), used to implement
6808 // backspace, delete, and similar functionality.
6809 function deleteNearSelection(cm, compute) {
6810 var ranges = cm.doc.sel.ranges, kill = [];
6811 // Build up a set of ranges to kill first, merging overlapping
6812 // ranges.
6813 for (var i = 0; i < ranges.length; i++) {
6814 var toKill = compute(ranges[i]);
6815 while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
6816 var replaced = kill.pop();
6817 if (cmp(replaced.from, toKill.from) < 0) {
6818 toKill.from = replaced.from;
6819 break
6820 }
6821 }
6822 kill.push(toKill);
6823 }
6824 // Next, remove those actual ranges.
6825 runInOp(cm, function () {
6826 for (var i = kill.length - 1; i >= 0; i--)
6827 { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); }
6828 ensureCursorVisible(cm);
6829 });
6830 }
6831
6832 function moveCharLogically(line, ch, dir) {
6833 var target = skipExtendingChars(line.text, ch + dir, dir);

Callers 2

codemirror.jsFile · 0.85
addEditorMethodsFunction · 0.85

Calls 5

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

Tested by

no test coverage detected