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

Continuation indent missing on lines after index expression #1540

Closed
OliverO2 opened this issue Jul 8, 2022 · 1 comment · Fixed by #1767
Closed

Continuation indent missing on lines after index expression #1540

OliverO2 opened this issue Jul 8, 2022 · 1 comment · Fixed by #1767
Labels
conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter indentation rule ktlint-official-codestyle
Milestone

Comments

@OliverO2
Copy link

OliverO2 commented Jul 8, 2022

Expected Behavior

    val a1 = a
        .aList[0].let {
            a // <---
        }

Observed Behavior

    val a1 = a
        .aList[0].let {
        a // <---
    }

Steps to Reproduce

class A(val a: A? = null) {
    val aList = listOf(this)
}

fun main() {
    val a = A(A(A()))

    val a1 = a
        .aList[0].let {
        a // <--- Oh, no!
    }

    val a2 = a
        .a.let {
            a // <--- The above should be like this.
        }
}

Your Environment

  • Version of ktlint used: 0.46.1
  • Relevant parts of the .editorconfig settings: none
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): id("com.diffplug.spotless") version "6.8.0"

Related

@paul-dingemans
Copy link
Collaborator

Tnx for taking the effort to raise an issue and including the reference to the IntelliJ issue.

I agree with you that the indenting of bot ktlint and IntelliJ IDEA default formatter is not correct in the case above. This can however not be fixed in ktlint until it is resolved in IntellI IDEA default formatter as well. Other wise it would result in a conflict between ktlint and the IDEA formatter which we currently still try to prevent (see discussion #1526).

@paul-dingemans paul-dingemans added indentation rule conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter labels Aug 16, 2022
paul-dingemans added a commit to paul-dingemans/ktlint that referenced this issue Jan 5, 2023
@paul-dingemans paul-dingemans added this to the 0.49.0 milestone Jan 16, 2023
paul-dingemans added a commit to paul-dingemans/ktlint that referenced this issue Jan 18, 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 indentation rule ktlint-official-codestyle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants