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

Function computeReplacedSel

samples/common/codehighlight/codemirror.js:4666–4683  ·  view source on GitHub ↗
(doc, changes, hint)

Source from the content-addressed store, hash-verified

4664 // Used by replaceSelections to allow moving the selection to the
4665 // start or around the replaced test. Hint may be "start" or "around".
4666 function computeReplacedSel(doc, changes, hint) {
4667 var out = [];
4668 var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
4669 for (var i = 0; i < changes.length; i++) {
4670 var change = changes[i];
4671 var from = offsetPos(change.from, oldPrev, newPrev);
4672 var to = offsetPos(changeEnd(change), oldPrev, newPrev);
4673 oldPrev = change.to;
4674 newPrev = to;
4675 if (hint == "around") {
4676 var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
4677 out[i] = new Range(inv ? to : from, inv ? from : to);
4678 } else {
4679 out[i] = new Range(from, from);
4680 }
4681 }
4682 return new Selection(out, doc.sel.primIndex)
4683 }
4684
4685 // Used to get the editor into a consistent state again when options change.
4686

Callers 1

codemirror.jsFile · 0.85

Calls 4

PosFunction · 0.85
offsetPosFunction · 0.85
changeEndFunction · 0.85
cmpFunction · 0.85

Tested by

no test coverage detected