Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkl-formatter/src/main/kotlin/org/pkl/formatter/Builder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ internal class Builder(sourceText: String, private val grammarVersion: GrammarVe
// skip semicolons
val children = children.filter { !it.isSemicolon() }
// short circuit
if (children.isEmpty()) return listOf(spaceOrLine())
if (children.isEmpty()) return emptyList()
if (children.size == 1) return listOf(format(children[0]))

val nodes = mutableListOf<FormatNode>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,11 @@ class FormatterTest {

walkDir(outputDir)
}

@Test
fun `whitespace only`() {
for (src in listOf(";;;", "\n", "\n\n\n", "\t")) {
assertThat(format(src)).isEqualTo("\n")
}
}
}
Loading