@internal
(chunk: Chunk, index: number)
| 945 | |
| 946 | /** @internal */ |
| 947 | _splitChunk(chunk: Chunk, index: number): true { |
| 948 | if (chunk.edited && chunk.content.length) { |
| 949 | // zero-length edited chunks are a special case (overlapping replacements) |
| 950 | const loc = getLocator(this.original)(index) |
| 951 | throw new Error( |
| 952 | `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`, |
| 953 | ) |
| 954 | } |
| 955 | |
| 956 | const newChunk = chunk.split(index) |
| 957 | |
| 958 | this.byEnd[index] = chunk |
| 959 | this.byStart[index] = newChunk |
| 960 | this.byEnd[newChunk.end] = newChunk |
| 961 | |
| 962 | if (chunk === this.lastChunk) |
| 963 | this.lastChunk = newChunk |
| 964 | |
| 965 | this.lastSearchedChunk = chunk |
| 966 | if (DEBUG) |
| 967 | this.stats.timeEnd('_split') |
| 968 | return true |
| 969 | } |
| 970 | |
| 971 | /** |
| 972 | * Returns the generated string. |
no test coverage detected