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

Format parameters in lambda #1756

Closed
paul-dingemans opened this issue Jan 1, 2023 · 2 comments
Closed

Format parameters in lambda #1756

paul-dingemans opened this issue Jan 1, 2023 · 2 comments
Milestone

Comments

@paul-dingemans
Copy link
Collaborator

It looks like ktlint 0.47.1 is not accepting that format in my project:

fun combine(a: Any, b: Any, c: (Any, Any) -> Unit) {
  c(a, b)
}

class Foo {
  fun foo() {
    combine(
      Any(),
      Any()
    ) { a,
        b ->
      TODO()
    }
  }
}

.editorconfig

[*.{kt,kts}]
indent_size = 2
indent_style = space

error

Foo.kt:11:1: Unexpected indentation (8) (should be 6) (indent)

Originally posted by @eygraber in #1681 (comment)

@paul-dingemans paul-dingemans added this to the 0.49.0 milestone Jan 1, 2023
paul-dingemans added a commit to paul-dingemans/ktlint that referenced this issue Jan 18, 2023
…meter list (only in `ktlint_official` code style).

Closes pinterest#1681

The parameters of a function literal containing a multiline parameter list are aligned with first parameter whenever the first parameter is on the same line as the start of that function literal (not allowed in `ktlint_official` code style)

Closes pinterest#1756
@eygraber
Copy link
Contributor

After updating to 0.49.0 this is still not working as ktlint expects the formatting to look like this:

fun combine(a: Any, b: Any, c: (Any, Any) -> Unit) {
  c(a, b)
}

class Foo {
  fun foo() {
    combine(
      Any(),
      Any()
    ) { a,
              b -> // Unexpected indentation (8) (should be 14) (standard:indent)
      TODO()
    }
  }
}

@paul-dingemans
Copy link
Collaborator Author

In 0.49.0 it works correctly for code style ktlint_official. With the other code styles the formatting is indeed incorrect. Will be fixed via #1976 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants