MCPcopy Index your code
hub / github.com/csev/py4e / rebaseHistArray

Function rebaseHistArray

tools/pythonauto/static/codemirrorepl/codemirror.js:6742–6768  ·  view source on GitHub ↗
(array, from, to, diff)

Source from the content-addressed store, hash-verified

6740 // reallocate them all on every rebase, but also avoid problems with
6741 // shared position objects being unsafely updated.
6742 function rebaseHistArray(array, from, to, diff) {
6743 for (var i = 0; i < array.length; ++i) {
6744 var sub = array[i], ok = true;
6745 if (sub.ranges) {
6746 if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
6747 for (var j = 0; j < sub.ranges.length; j++) {
6748 rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
6749 rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
6750 }
6751 continue;
6752 }
6753 for (var j = 0; j < sub.changes.length; ++j) {
6754 var cur = sub.changes[j];
6755 if (to < cur.from.line) {
6756 cur.from = Pos(cur.from.line + diff, cur.from.ch);
6757 cur.to = Pos(cur.to.line + diff, cur.to.ch);
6758 } else if (from <= cur.to.line) {
6759 ok = false;
6760 break;
6761 }
6762 }
6763 if (!ok) {
6764 array.splice(0, i + 1);
6765 i = 0;
6766 }
6767 }
6768 }
6769
6770 function rebaseHist(hist, change) {
6771 var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;

Callers 1

rebaseHistFunction · 0.70

Calls 2

rebaseHistSelSingleFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected