MCPcopy Create free account
hub / github.com/TruthHun/BookStack / adjustForChange

Function adjustForChange

static/mergely/lib/codemirror.js:4286–4293  ·  view source on GitHub ↗
(pos, change)

Source from the content-addressed store, hash-verified

4284 // Adjust a position to refer to the post-change position of the
4285 // same text, or the end of the change if the change covers it.
4286 function adjustForChange(pos, change) {
4287 if (cmp(pos, change.from) < 0) return pos;
4288 if (cmp(pos, change.to) <= 0) return changeEnd(change);
4289
4290 var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
4291 if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
4292 return Pos(line, ch);
4293 }
4294
4295 function computeSelAfterChange(doc, change) {
4296 var out = [];

Callers 1

computeSelAfterChangeFunction · 0.70

Calls 1

cmpFunction · 0.50

Tested by

no test coverage detected