@internal
(chunk: Chunk, index: number)
| 962 | |
| 963 | /** @internal */ |
| 964 | _splitChunk(chunk: Chunk, index: number): true { |
| 965 | if (chunk.edited && chunk.content.length) { |
| 966 | // zero-length edited chunks are a special case (overlapping replacements) |
| 967 | const loc = getLocator(this.original)(index) |
| 968 | throw new MagicStringError( |
| 969 | `cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`, |
| 970 | ) |
| 971 | } |
| 972 | |
| 973 | const newChunk = chunk.split(index) |
| 974 | |
| 975 | this.byEnd.set(index, chunk) |
| 976 | this.byStart.set(index, newChunk) |
| 977 | this.byEnd.set(newChunk.end, newChunk) |
| 978 | |
| 979 | if (chunk === this.lastChunk) |
| 980 | this.lastChunk = newChunk |
| 981 | |
| 982 | this.lastSearchedChunk = chunk |
| 983 | if (DEBUG) |
| 984 | this.stats.timeEnd('_split') |
| 985 | return true |
| 986 | } |
| 987 | |
| 988 | /** |
| 989 | * Returns the generated string. |
no test coverage detected