(array, from, to, diff)
| 293 | // reallocate them all on every rebase, but also avoid problems with |
| 294 | // shared position objects being unsafely updated. |
| 295 | function rebaseHistArray(array, from, to, diff) { |
| 296 | for (let i = 0; i < array.length; ++i) { |
| 297 | let sub = array[i], ok = true |
| 298 | if (sub.ranges) { |
| 299 | if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true } |
| 300 | for (let j = 0; j < sub.ranges.length; j++) { |
| 301 | rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff) |
| 302 | rebaseHistSelSingle(sub.ranges[j].head, from, to, diff) |
| 303 | } |
| 304 | continue |
| 305 | } |
| 306 | for (let j = 0; j < sub.changes.length; ++j) { |
| 307 | let cur = sub.changes[j] |
| 308 | if (to < cur.from.line) { |
| 309 | cur.from = Pos(cur.from.line + diff, cur.from.ch) |
| 310 | cur.to = Pos(cur.to.line + diff, cur.to.ch) |
| 311 | } else if (from <= cur.to.line) { |
| 312 | ok = false |
| 313 | break |
| 314 | } |
| 315 | } |
| 316 | if (!ok) { |
| 317 | array.splice(0, i + 1) |
| 318 | i = 0 |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | function rebaseHist(hist, change) { |
| 324 | let from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1 |
no test coverage detected