Skip to content
New issue

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

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

Already on GitHub? # to your account

Intentation removed from lines continuing a val declaration on the previous line #1840

Closed
rvandermeulen opened this issue Mar 3, 2023 · 4 comments

Comments

@rvandermeulen
Copy link

Sorry in advance if I missed this searching for existing reports! I looked, I swear 😄

Expected Behavior

I was recently updating our project from 0.47.0 to 0.48.2 and observed some odd-looking indentation changes made by ktlintFormat. No config changes were made, just the version bump and subsequent ktlintFormat run.

I would have expected the code below to have been left untouched:

    private val customFirstPartyDownloadDialog:
        ((Filename, ContentSize, PositiveActionCallback, NegativeActionCallback) -> Unit)? = null,

Observed Behavior

ktlintFormat removed the indentation from the second line:

     private val customFirstPartyDownloadDialog:
-        ((Filename, ContentSize, PositiveActionCallback, NegativeActionCallback) -> Unit)? = null,
+    ((Filename, ContentSize, PositiveActionCallback, NegativeActionCallback) -> Unit)? = null,

I saw the same changes made elsewhere as well for code fitting the same pattern.

Steps to Reproduce

Here's a link to the raw file in case more context is needed than just the snippet above:
https://github.com/mozilla-mobile/firefox-android/blob/777a9f3ab0309cbff5758e1d34868f61560aff8d/android-components/components/feature/downloads/src/main/java/mozilla/components/feature/downloads/DownloadsFeature.kt

Your Environment

  • Version of ktlint used: 0.48.2
  • Version of Gradle used (if applicable): 7.6.1
@paul-dingemans
Copy link
Collaborator

It could be that the behavior is changed in 0.48.x. The indent rule has been rewritten from scratch. The current formatting is in sync with the behavior of IntelliJ IDEA default formatting. But the current formatting is less clear. I will take this into account with the new code style on which I am working.

@paul-dingemans paul-dingemans added conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter ktlint-official-codestyle and removed conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter labels Mar 4, 2023
@paul-dingemans
Copy link
Collaborator

Is it correct that your code sample is part of a class constructor or function signature? I did not notice the trailing comma before.

If so, than this is an intended change in order to be compatible with IntelliJ IDEA default formatting. In 0.49.x a new code style will be added that drops the requirement for being compatible with the default IDEA formatting and the continuation indent for class and function parameters will be fixed when using that code style (see #1846).

@rvandermeulen
Copy link
Author

Yeah, it's in the class constructor. Thanks for the follow-up!

@paul-dingemans paul-dingemans added this to the 0.49.0 milestone Mar 9, 2023
@paul-dingemans
Copy link
Collaborator

Resolved by #1846

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants