Skip to content
Closed
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
5 changes: 4 additions & 1 deletion pkl-formatter/src/main/kotlin/org/pkl/formatter/Builder.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1302,7 +1302,10 @@ internal class Builder(sourceText: String, private val grammarVersion: GrammarVe
}

private fun getBaseSeparator(prev: Node, next: Node): FormatNode? {

return when {
endsInLineComment(prev) && endsInLineComment(next) -> mustForceLine()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too broad of a fix. You are changing how every line comment gets formatted.

// foo

// bar

The above code will have the newlines removed. You have to fix the import list specifically if you want to remove newlines from there.


endsInLineComment(prev) -> {
if (prev.linesBetween(next) > 1) {
TWO_NEWLINES
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "pkl:json" // used for doc comments
import "pkl:jsonnet"
import "pkl:math" // used for doc comments
import "pkl:pklbinary"
import "pkl:protobuf"
import "pkl:xml"
import "pkl:yaml" // used for doc comments
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// used for doc comments
// used for doc comments
// used for doc comments
import "pkl:json"
import "pkl:jsonnet"
import "pkl:math"
import "pkl:pklbinary"
import "pkl:protobuf"
import "pkl:xml"
import "pkl:yaml"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading