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

Trailing assignments on next line are missing continuation indent in 0.43.0 #1268

Closed
ZacSweers opened this issue Nov 2, 2021 · 8 comments
Closed

Comments

@ZacSweers
Copy link

ZacSweers commented Nov 2, 2021

Expected Behavior

I expect it to be indented

Observed Behavior

It is indenting to the same indent as the previous line (screenshot is before/after diff when running 0.43.0)

image

Steps to Reproduce

private val richTextSections =
  listOf(
    RichTextSection(
      chunks =
        // This gets indented back to align with the chunks name
        listOf(
          TextChunk(text = "test")
        )
    )
  )

Your Environment

  • Version of ktlint used: 0.43.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): Spotless
  • Version of Gradle used (if applicable): N/A
  • Operating System and version: N/A
  • Link to your project (if it's a public repository): N/A
@ZacSweers
Copy link
Author

Actually it appears to affect everything in the expression after the assignment, not just the start of it

image

@shashachu
Copy link
Contributor

@ZacSweers thanks for the report. Are you able to run with the --verbose flag to confirm which rule is causing the issue?

@ZacSweers
Copy link
Author

I don't see any extra output with that flag

$ ./config/bin/ktlint -F --verbose /Users/zsweers/path/to/file.kt
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil (file:/Users/zsweers/dev/slack/restructure/slack-android-ng/config/bin/ktlint) to field java.lang.Throwable.backtrace
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

@romtsn
Copy link
Collaborator

romtsn commented Nov 4, 2021

@ZacSweers please run it w/o the -F option, then it should give the affected lines and the rule id

@ZacSweers
Copy link
Author

ZacSweers commented Nov 4, 2021

Ah ok, here you go

$ ./config/bin/ktlint --verbose path/to/file.kt
path/to/file.kt:67:1: Unexpected indentation (10) (should be 8) (indent)
path/to/file.kt:68:1: Unexpected indentation (12) (should be 10) (indent)
path/to/file.kt:69:1: Unexpected indentation (10) (should be 8) (indent)

Where line 67 is the listOf( statement

@paul-dingemans
Copy link
Collaborator

This was explicitly implemented in #964. I have checked, and this is still the way that IntelliJ Ultimate formats the example. Personally, I would prefer to have the indented it as well ;-)

@DenWav
Copy link

DenWav commented Dec 18, 2021

Wait so this is intended behavior? That can't be right, it's clearly wrong.

@paul-dingemans
Copy link
Collaborator

This was explicitly implemented in #964. I have checked, and this is still the way that IntelliJ Ultimate formats the example. Personally, I would prefer to have the indented it as well ;-)

Removing the "bug" label and add "won't fix".

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

5 participants