(index)
| 659 | } |
| 660 | |
| 661 | _split(index) { |
| 662 | if (this.byStart[index] || this.byEnd[index]) return; |
| 663 | |
| 664 | if (DEBUG) this.stats.time('_split'); |
| 665 | |
| 666 | let chunk = this.lastSearchedChunk; |
| 667 | let previousChunk = chunk; |
| 668 | const searchForward = index > chunk.end; |
| 669 | |
| 670 | while (chunk) { |
| 671 | if (chunk.contains(index)) return this._splitChunk(chunk, index); |
| 672 | |
| 673 | chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start]; |
| 674 | |
| 675 | // Prevent infinite loop (e.g. via empty chunks, where start === end) |
| 676 | if (chunk === previousChunk) return; |
| 677 | |
| 678 | previousChunk = chunk; |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | _splitChunk(chunk, index) { |
| 683 | if (chunk.edited && chunk.content.length) { |
no test coverage detected