@internal
(chunk: Chunk, index: number)
| 1001 | |
| 1002 | /** @internal */ |
| 1003 | _splitChunk(chunk: Chunk, index: number): true { |
| 1004 | if (chunk.edited && chunk.content.length) { |
| 1005 | // zero-length edited chunks are a special case (overlapping replacements) |
| 1006 | const loc = getLocator(this.original)(index) |
| 1007 | throw new MagicStringError( |
| 1008 | `cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`, |
| 1009 | ) |
| 1010 | } |
| 1011 | |
| 1012 | const newChunk = chunk.split(index) |
| 1013 | |
| 1014 | this.byEnd.set(index, chunk) |
| 1015 | this.byStart.set(index, newChunk) |
| 1016 | this.byEnd.set(newChunk.end, newChunk) |
| 1017 | |
| 1018 | if (chunk === this.lastChunk) |
| 1019 | this.lastChunk = newChunk |
| 1020 | |
| 1021 | this.lastSearchedChunk = chunk |
| 1022 | if (DEBUG) |
| 1023 | this.stats.timeEnd('_split') |
| 1024 | return true |
| 1025 | } |
| 1026 | |
| 1027 | /** |
| 1028 | * Returns the generated string. |
no test coverage detected