MCPcopy Index your code
hub / github.com/csev/py4e / computeReplacedSel

Function computeReplacedSel

tools/pythonauto/static/codemirrorepl/codemirror.js:3216–3233  ·  view source on GitHub ↗
(doc, changes, hint)

Source from the content-addressed store, hash-verified

3214 // Used by replaceSelections to allow moving the selection to the
3215 // start or around the replaced test. Hint may be "start" or "around".
3216 function computeReplacedSel(doc, changes, hint) {
3217 var out = [];
3218 var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
3219 for (var i = 0; i < changes.length; i++) {
3220 var change = changes[i];
3221 var from = offsetPos(change.from, oldPrev, newPrev);
3222 var to = offsetPos(changeEnd(change), oldPrev, newPrev);
3223 oldPrev = change.to;
3224 newPrev = to;
3225 if (hint == "around") {
3226 var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
3227 out[i] = new Range(inv ? to : from, inv ? from : to);
3228 } else {
3229 out[i] = new Range(from, from);
3230 }
3231 }
3232 return new Selection(out, doc.sel.primIndex);
3233 }
3234
3235 // Allow "beforeChange" event handlers to influence a change
3236 function filterChange(doc, change, update) {

Callers 1

codemirror.jsFile · 0.85

Calls 3

PosFunction · 0.85
offsetPosFunction · 0.85
cmpFunction · 0.85

Tested by

no test coverage detected