@internal
(chunk: Chunk, index: number)
| 1203 | |
| 1204 | /** @internal */ |
| 1205 | _splitChunk(chunk: Chunk, index: number): true { |
| 1206 | if (chunk.edited && chunk.content.length) { |
| 1207 | // zero-length edited chunks are a special case (overlapping replacements) |
| 1208 | const loc = getLocator(this.original)(index) |
| 1209 | throw new MagicStringError( |
| 1210 | `cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`, |
| 1211 | ) |
| 1212 | } |
| 1213 | |
| 1214 | const newChunk = chunk.split(index) |
| 1215 | |
| 1216 | this.byEnd.set(index, chunk) |
| 1217 | this.byStart.set(index, newChunk) |
| 1218 | this.byEnd.set(newChunk.end, newChunk) |
| 1219 | |
| 1220 | if (chunk === this.lastChunk) |
| 1221 | this.lastChunk = newChunk |
| 1222 | |
| 1223 | this.lastSearchedChunk = chunk |
| 1224 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 1225 | if (DEBUG) |
| 1226 | this.stats.timeEnd('_split') |
| 1227 | return true |
| 1228 | } |
| 1229 | |
| 1230 | /** |
| 1231 | * Returns the generated string. |
no test coverage detected