(array, from, to, diff)
| 5424 | // reallocate them all on every rebase, but also avoid problems with |
| 5425 | // shared position objects being unsafely updated. |
| 5426 | function rebaseHistArray(array, from, to, diff) { |
| 5427 | for (var i = 0; i < array.length; ++i) { |
| 5428 | var sub = array[i], ok = true; |
| 5429 | for (var j = 0; j < sub.changes.length; ++j) { |
| 5430 | var cur = sub.changes[j]; |
| 5431 | if (!sub.copied) { cur.from = copyPos(cur.from); cur.to = copyPos(cur.to); } |
| 5432 | if (to < cur.from.line) { |
| 5433 | cur.from.line += diff; |
| 5434 | cur.to.line += diff; |
| 5435 | } else if (from <= cur.to.line) { |
| 5436 | ok = false; |
| 5437 | break; |
| 5438 | } |
| 5439 | } |
| 5440 | if (!sub.copied) { |
| 5441 | sub.anchorBefore = copyPos(sub.anchorBefore); sub.headBefore = copyPos(sub.headBefore); |
| 5442 | sub.anchorAfter = copyPos(sub.anchorAfter); sub.readAfter = copyPos(sub.headAfter); |
| 5443 | sub.copied = true; |
| 5444 | } |
| 5445 | if (!ok) { |
| 5446 | array.splice(0, i + 1); |
| 5447 | i = 0; |
| 5448 | } else { |
| 5449 | rebaseHistSel(sub.anchorBefore); rebaseHistSel(sub.headBefore); |
| 5450 | rebaseHistSel(sub.anchorAfter); rebaseHistSel(sub.headAfter); |
| 5451 | } |
| 5452 | } |
| 5453 | } |
| 5454 | |
| 5455 | function rebaseHist(hist, change) { |
| 5456 | var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; |
no test coverage detected