MCPcopy Create free account
hub / github.com/breck7/scroll / deleteNearSelection

Function deleteNearSelection

external/.scrollLibs.js:9302–9325  ·  view source on GitHub ↗
(cm, compute)

Source from the content-addressed store, hash-verified

9300 // Helper for deleting text near the selection(s), used to implement
9301 // backspace, delete, and similar functionality.
9302 function deleteNearSelection(cm, compute) {
9303 var ranges = cm.doc.sel.ranges,
9304 kill = []
9305 // Build up a set of ranges to kill first, merging overlapping
9306 // ranges.
9307 for (var i = 0; i < ranges.length; i++) {
9308 var toKill = compute(ranges[i])
9309 while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
9310 var replaced = kill.pop()
9311 if (cmp(replaced.from, toKill.from) < 0) {
9312 toKill.from = replaced.from
9313 break
9314 }
9315 }
9316 kill.push(toKill)
9317 }
9318 // Next, remove those actual ranges.
9319 runInOp(cm, function () {
9320 for (var i = kill.length - 1; i >= 0; i--) {
9321 replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete")
9322 }
9323 ensureCursorVisible(cm)
9324 })
9325 }
9326
9327 function moveCharLogically(line, ch, dir) {
9328 var target = skipExtendingChars(line.text, ch + dir, dir)

Callers 2

.scrollLibs.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