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

Errant comma added between parameter lambda and parenthesis (when trailing lambda present) #1557

Closed
JakeWharton opened this issue Jul 26, 2022 · 6 comments
Labels
conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter trailing-comma rule
Milestone

Comments

@JakeWharton
Copy link
Contributor

ktlint 0.46.1

Rules:

        'disabled_rules': 'filename',
        'insert_final_newline': 'true',
        'end_of_line': 'lf',
        'indent_size': '2',
        'ij_kotlin_allow_trailing_comma': 'true',
        'ij_kotlin_allow_trailing_comma_on_call_site': 'true',
        'ij_kotlin_imports_layout': '*',

Input:

fun twoLambdas(one: () -> Unit, two: () -> Unit) = Unit

fun test() {
  twoLambdas({
    println("one")
  }) {
    println("two")
  }
}

Actual output:

 fun twoLambdas(one: () -> Unit, two: () -> Unit) = Unit

 fun test() {
   twoLambdas({
     println("one")
-  }) {
+  },) {
     println("two")
   }
}

Expected output:

No change from input.

@paul-dingemans
Copy link
Collaborator

Tnx for reporting. This bug already seems to be around since version 0.42.x. The trailing comma should not be added to the argument list whenever a function call is followed by a lambda.

@JakeWharton
Copy link
Contributor Author

Heh, I was upgrading from 0.41 😄

@paul-dingemans
Copy link
Collaborator

Tnx for reporting. This bug already seems to be around since version 0.42.x. The trailing comma should not be added to the argument list whenever a function call is followed by a lambda.

Current behavior of KtLint is consistent with default formatting of IntelliJ IDEA. Omitting the trailing comma in this would lead to a conflict with IntelliJ IDEA. As of that it can not be fixed in KtLint for now (see #1526).

@paul-dingemans paul-dingemans added conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter and removed bug labels Aug 14, 2022
@paul-dingemans paul-dingemans removed this from the 0.47.0 milestone Aug 14, 2022
@Hexcles
Copy link

Hexcles commented Sep 28, 2022

@paul-dingemans
Copy link
Collaborator

I do agree with you that this is a bug on the IntelliJ side. Tnx for creating the bug there and copy the reference here.

@paul-dingemans
Copy link
Collaborator

Resolved by #1648 in version 0.48.0.

@paul-dingemans paul-dingemans added this to the 0.48.0 milestone Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter trailing-comma rule
Projects
None yet
Development

No branches or pull requests

3 participants