MCPcopy
hub / github.com/DHTMLX/gantt / adjustForChange

Function adjustForChange

samples/common/codehighlight/codemirror.js:4638–4645  ·  view source on GitHub ↗
(pos, change)

Source from the content-addressed store, hash-verified

4636 // Adjust a position to refer to the post-change position of the
4637 // same text, or the end of the change if the change covers it.
4638 function adjustForChange(pos, change) {
4639 if (cmp(pos, change.from) < 0) { return pos }
4640 if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
4641
4642 var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
4643 if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; }
4644 return Pos(line, ch)
4645 }
4646
4647 function computeSelAfterChange(doc, change) {
4648 var out = [];

Callers 1

computeSelAfterChangeFunction · 0.85

Calls 3

cmpFunction · 0.85
changeEndFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected