* Returns everything after the last newline in the generated string, or the whole string if there is no newline.
()
| 988 | * Returns everything after the last newline in the generated string, or the whole string if there is no newline. |
| 989 | */ |
| 990 | lastLine(): string { |
| 991 | let lineIndex = this.outro.lastIndexOf(n) |
| 992 | if (lineIndex !== -1) |
| 993 | return this.outro.slice(lineIndex + 1) |
| 994 | let lineStr = this.outro |
| 995 | let chunk: Chunk | null = this.lastChunk |
| 996 | while (chunk) { |
| 997 | if (chunk.outro.length > 0) { |
| 998 | lineIndex = chunk.outro.lastIndexOf(n) |
| 999 | if (lineIndex !== -1) |
| 1000 | return chunk.outro.slice(lineIndex + 1) + lineStr |
| 1001 | lineStr = chunk.outro + lineStr |
| 1002 | } |
| 1003 | |
| 1004 | if (chunk.content.length > 0) { |
| 1005 | lineIndex = chunk.content.lastIndexOf(n) |
| 1006 | if (lineIndex !== -1) |
| 1007 | return chunk.content.slice(lineIndex + 1) + lineStr |
| 1008 | lineStr = chunk.content + lineStr |
| 1009 | } |
| 1010 | |
| 1011 | if (chunk.intro.length > 0) { |
| 1012 | lineIndex = chunk.intro.lastIndexOf(n) |
| 1013 | if (lineIndex !== -1) |
| 1014 | return chunk.intro.slice(lineIndex + 1) + lineStr |
| 1015 | lineStr = chunk.intro + lineStr |
| 1016 | } |
| 1017 | chunk = chunk.previous |
| 1018 | } |
| 1019 | lineIndex = this.intro.lastIndexOf(n) |
| 1020 | if (lineIndex !== -1) |
| 1021 | return this.intro.slice(lineIndex + 1) + lineStr |
| 1022 | return this.intro + lineStr |
| 1023 | } |
| 1024 | |
| 1025 | /** |
| 1026 | * Returns the content of the generated string that corresponds to the slice |