diff --git a/core/src/main/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemover.kt b/core/src/main/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemover.kt index f207eb0..85d014f 100644 --- a/core/src/main/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemover.kt +++ b/core/src/main/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemover.kt @@ -43,7 +43,7 @@ public class CommentsInBlockRemover private constructor( private val errorListener: CollectingErrorListener, private val blockName: String, ) : KotlinParserBaseListener() { - private var terminalNewlines = 0 + private var terminalNewlines = Whitespace.countTerminalNewlines(tokens) private val rewriter = Rewriter(tokens) private val indent = Whitespace.computeIndent(tokens, input) private val comments = Comments(tokens, indent) diff --git a/core/src/test/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemoverTest.kt b/core/src/test/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemoverTest.kt index 87ccf5f..3ca5ba7 100644 --- a/core/src/test/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemoverTest.kt +++ b/core/src/test/kotlin/cash/grammar/kotlindsl/utils/CommentsInBlockRemoverTest.kt @@ -23,6 +23,7 @@ class CommentsInBlockRemoverTest { |otherBlock { | // More comments |} + | """.trimMargin() // When @@ -42,6 +43,7 @@ class CommentsInBlockRemoverTest { |otherBlock { | // More comments |} + | """.trimMargin()) assertThat(commentsInBlockRemover.getFoundRemovableComments()).containsOnly( "/* This is a block comment\n that spans multiple lines */",