Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop emitting multiple trailing commas in enum entry lists with multiline items #458

Closed
wants to merge 1 commit into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ object TrailingCommas {
}

when (element) {
is KtEnumEntry, // Only suggest on the KtClassBody container
is KtWhenEntry -> return
is KtParameterList -> {
if (element.parent is KtFunctionLiteral && element.parent.parent is KtLambdaExpression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,26 @@ class GoogleStyleFormatterKtTest {
formattingOptions = Formatter.GOOGLE_FORMAT,
deduceMaxWidth = true)

@Test
fun `trailing commas on multline enum entries`() =
assertFormatted(
"""
|enum class MultilineEntries {
| A(
| arg = 0, //
| arg = 0,
| ),
| /* Comment */
| B,
| C {
| fun foo() {}
| },
|}
|"""
.trimMargin(),
formattingOptions = Formatter.GOOGLE_FORMAT)


@Test
fun `trailing commas in enums`() {
val code =
Expand Down
Loading