MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / rebaseHistArray

Function rebaseHistArray

static/js/codemirror/codemirror.js:4777–4804  ·  view source on GitHub ↗
(array, from, to, diff)

Source from the content-addressed store, hash-verified

4775 // reallocate them all on every rebase, but also avoid problems with
4776 // shared position objects being unsafely updated.
4777 function rebaseHistArray(array, from, to, diff) {
4778 for (var i = 0; i < array.length; ++i) {
4779 var sub = array[i], ok = true;
4780 for (var j = 0; j < sub.changes.length; ++j) {
4781 var cur = sub.changes[j];
4782 if (!sub.copied) { cur.from = copyPos(cur.from); cur.to = copyPos(cur.to); }
4783 if (to < cur.from.line) {
4784 cur.from.line += diff;
4785 cur.to.line += diff;
4786 } else if (from <= cur.to.line) {
4787 ok = false;
4788 break;
4789 }
4790 }
4791 if (!sub.copied) {
4792 sub.anchorBefore = copyPos(sub.anchorBefore); sub.headBefore = copyPos(sub.headBefore);
4793 sub.anchorAfter = copyPos(sub.anchorAfter); sub.readAfter = copyPos(sub.headAfter);
4794 sub.copied = true;
4795 }
4796 if (!ok) {
4797 array.splice(0, i + 1);
4798 i = 0;
4799 } else {
4800 rebaseHistSel(sub.anchorBefore); rebaseHistSel(sub.headBefore);
4801 rebaseHistSel(sub.anchorAfter); rebaseHistSel(sub.headAfter);
4802 }
4803 }
4804 }
4805
4806 function rebaseHist(hist, change) {
4807 var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;

Callers 1

rebaseHistFunction · 0.85

Calls 2

copyPosFunction · 0.85
rebaseHistSelFunction · 0.85

Tested by

no test coverage detected