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