MCPcopy Create free account
hub / github.com/sql-js/sql.js / rebaseHistArray

Function rebaseHistArray

GUI/codemirror/lib/codemirror.js:6792–6818  ·  view source on GitHub ↗
(array, from, to, diff)

Source from the content-addressed store, hash-verified

6790 // reallocate them all on every rebase, but also avoid problems with
6791 // shared position objects being unsafely updated.
6792 function rebaseHistArray(array, from, to, diff) {
6793 for (var i = 0; i < array.length; ++i) {
6794 var sub = array[i], ok = true;
6795 if (sub.ranges) {
6796 if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
6797 for (var j = 0; j < sub.ranges.length; j++) {
6798 rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
6799 rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
6800 }
6801 continue;
6802 }
6803 for (var j = 0; j < sub.changes.length; ++j) {
6804 var cur = sub.changes[j];
6805 if (to < cur.from.line) {
6806 cur.from = Pos(cur.from.line + diff, cur.from.ch);
6807 cur.to = Pos(cur.to.line + diff, cur.to.ch);
6808 } else if (from <= cur.to.line) {
6809 ok = false;
6810 break;
6811 }
6812 }
6813 if (!ok) {
6814 array.splice(0, i + 1);
6815 i = 0;
6816 }
6817 }
6818 }
6819
6820 function rebaseHist(hist, change) {
6821 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…