MCPcopy Index your code
hub / github.com/witheve/Eve / rebaseHistArray

Function rebaseHistArray

src/codemirror.js:8107–8133  ·  view source on GitHub ↗
(array, from, to, diff)

Source from the content-addressed store, hash-verified

8105 // reallocate them all on every rebase, but also avoid problems with
8106 // shared position objects being unsafely updated.
8107 function rebaseHistArray(array, from, to, diff) {
8108 for (var i = 0; i < array.length; ++i) {
8109 var sub = array[i], ok = true;
8110 if (sub.ranges) {
8111 if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
8112 for (var j = 0; j < sub.ranges.length; j++) {
8113 rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
8114 rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
8115 }
8116 continue;
8117 }
8118 for (var j = 0; j < sub.changes.length; ++j) {
8119 var cur = sub.changes[j];
8120 if (to < cur.from.line) {
8121 cur.from = Pos(cur.from.line + diff, cur.from.ch);
8122 cur.to = Pos(cur.to.line + diff, cur.to.ch);
8123 } else if (from <= cur.to.line) {
8124 ok = false;
8125 break;
8126 }
8127 }
8128 if (!ok) {
8129 array.splice(0, i + 1);
8130 i = 0;
8131 }
8132 }
8133 }
8134
8135 function rebaseHist(hist, change) {
8136 var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;

Callers 1

rebaseHistFunction · 0.85

Calls 1

rebaseHistSelSingleFunction · 0.85

Tested by

no test coverage detected