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

Function rebaseHistArray

samples/common/codehighlight/codemirror.js:5513–5539  ·  view source on GitHub ↗
(array, from, to, diff)

Source from the content-addressed store, hash-verified

5511 // reallocate them all on every rebase, but also avoid problems with
5512 // shared position objects being unsafely updated.
5513 function rebaseHistArray(array, from, to, diff) {
5514 for (var i = 0; i < array.length; ++i) {
5515 var sub = array[i], ok = true;
5516 if (sub.ranges) {
5517 if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
5518 for (var j = 0; j < sub.ranges.length; j++) {
5519 rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
5520 rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
5521 }
5522 continue
5523 }
5524 for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
5525 var cur = sub.changes[j$1];
5526 if (to < cur.from.line) {
5527 cur.from = Pos(cur.from.line + diff, cur.from.ch);
5528 cur.to = Pos(cur.to.line + diff, cur.to.ch);
5529 } else if (from <= cur.to.line) {
5530 ok = false;
5531 break
5532 }
5533 }
5534 if (!ok) {
5535 array.splice(0, i + 1);
5536 i = 0;
5537 }
5538 }
5539 }
5540
5541 function rebaseHist(hist, change) {
5542 var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;

Callers 1

rebaseHistFunction · 0.85

Calls 2

rebaseHistSelSingleFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected