MCPcopy Create free account
hub / github.com/breck7/scroll / rebaseHistArray

Function rebaseHistArray

external/.scrollLibs.js:7441–7471  ·  view source on GitHub ↗
(array, from, to, diff)

Source from the content-addressed store, hash-verified

7439 // reallocate them all on every rebase, but also avoid problems with
7440 // shared position objects being unsafely updated.
7441 function rebaseHistArray(array, from, to, diff) {
7442 for (var i = 0; i < array.length; ++i) {
7443 var sub = array[i],
7444 ok = true
7445 if (sub.ranges) {
7446 if (!sub.copied) {
7447 sub = array[i] = sub.deepCopy()
7448 sub.copied = true
7449 }
7450 for (var j = 0; j < sub.ranges.length; j++) {
7451 rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)
7452 rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)
7453 }
7454 continue
7455 }
7456 for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
7457 var cur = sub.changes[j$1]
7458 if (to < cur.from.line) {
7459 cur.from = Pos(cur.from.line + diff, cur.from.ch)
7460 cur.to = Pos(cur.to.line + diff, cur.to.ch)
7461 } else if (from <= cur.to.line) {
7462 ok = false
7463 break
7464 }
7465 }
7466 if (!ok) {
7467 array.splice(0, i + 1)
7468 i = 0
7469 }
7470 }
7471 }
7472
7473 function rebaseHist(hist, change) {
7474 var from = change.from.line,

Callers 1

rebaseHistFunction · 0.85

Calls 2

rebaseHistSelSingleFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected