@internal
(chunk: Chunk, index: number)
| 1171 | |
| 1172 | /** @internal */ |
| 1173 | _splitChunk(chunk: Chunk, index: number): true { |
| 1174 | if (chunk.edited && chunk.content.length) { |
| 1175 | // zero-length edited chunks are a special case (overlapping replacements) |
| 1176 | const loc = getLocator(this.original)(index) |
| 1177 | throw new MagicStringError( |
| 1178 | `cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`, |
| 1179 | ) |
| 1180 | } |
| 1181 | |
| 1182 | const newChunk = chunk.split(index) |
| 1183 | |
| 1184 | this.byEnd.set(index, chunk) |
| 1185 | this.byStart.set(index, newChunk) |
| 1186 | this.byEnd.set(newChunk.end, newChunk) |
| 1187 | |
| 1188 | if (chunk === this.lastChunk) |
| 1189 | this.lastChunk = newChunk |
| 1190 | |
| 1191 | this.lastSearchedChunk = chunk |
| 1192 | return true |
| 1193 | } |
| 1194 | |
| 1195 | /** |
| 1196 | * Returns the generated string. |
no test coverage detected