@internal
(chunk: Chunk, index: number)
| 1107 | |
| 1108 | /** @internal */ |
| 1109 | _splitChunk(chunk: Chunk, index: number): true { |
| 1110 | if (chunk.edited && chunk.content.length) { |
| 1111 | // zero-length edited chunks are a special case (overlapping replacements) |
| 1112 | const loc = getLocator(this.original)(index) |
| 1113 | throw new MagicStringError( |
| 1114 | `cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`, |
| 1115 | ) |
| 1116 | } |
| 1117 | |
| 1118 | const newChunk = chunk.split(index) |
| 1119 | |
| 1120 | this.byEnd.set(index, chunk) |
| 1121 | this.byStart.set(index, newChunk) |
| 1122 | this.byEnd.set(newChunk.end, newChunk) |
| 1123 | |
| 1124 | if (chunk === this.lastChunk) |
| 1125 | this.lastChunk = newChunk |
| 1126 | |
| 1127 | this.lastSearchedChunk = chunk |
| 1128 | if (DEBUG) |
| 1129 | this.stats.timeEnd('_split') |
| 1130 | return true |
| 1131 | } |
| 1132 | |
| 1133 | /** |
| 1134 | * Returns the generated string. |
no test coverage detected