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

Function adjustForChange

static/editor.md/lib/codemirror/lib/codemirror.js:4107–4114  ·  view source on GitHub ↗
(pos, change)

Source from the content-addressed store, hash-verified

4105 // Adjust a position to refer to the post-change position of the
4106 // same text, or the end of the change if the change covers it.
4107 function adjustForChange(pos, change) {
4108 if (cmp(pos, change.from) < 0) return pos;
4109 if (cmp(pos, change.to) <= 0) return changeEnd(change);
4110
4111 var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
4112 if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
4113 return Pos(line, ch);
4114 }
4115
4116 function computeSelAfterChange(doc, change) {
4117 var out = [];

Callers 1

computeSelAfterChangeFunction · 0.70

Calls 1

cmpFunction · 0.50

Tested by

no test coverage detected