Skip to content

Commit 276dea2

Browse files
committed
hopefully better sameLine builder function
1 parent aa6966c commit 276dea2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/kotlin/com/lambda/interaction/request/LogContext.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ interface LogContext {
5252
private var tabs = tabMin
5353

5454
@LogContextDsl
55-
fun sameLine() =
56-
logContext.replace("\n", "")
55+
fun sameLine() {
56+
val length = logContext.length
57+
val first = logContext[length - 2]
58+
val second = logContext[length - 1]
59+
if (first != '\\' || second != 'n') throw IllegalStateException("String does not end in a new line")
60+
logContext = logContext.removeRange(length - 2, length - 1)
61+
}
5762

5863
@LogContextDsl
5964
fun text(text: String) {

0 commit comments

Comments
 (0)