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

Annotation formatting conflicts with IntelliJ IDEA / Android Studio #1639

Closed
PaulWoitaschek opened this issue Sep 9, 2022 · 3 comments · Fixed by #1682
Closed

Annotation formatting conflicts with IntelliJ IDEA / Android Studio #1639

PaulWoitaschek opened this issue Sep 9, 2022 · 3 comments · Fixed by #1682
Labels
conflict-with-default-intellij-formatting Code produced by KtLint is not accepted by the IntelliJ default formatter indentation rule
Milestone

Comments

@PaulWoitaschek
Copy link
Contributor

Field annotations are formatted by AS like this:

package mypackage

private annotation class A
private annotation class B

private class C {
  @field: [
  A
  B
  ]
  val a: Int = 42
}

Is reformatted by ktlint to:

package mypackage

private annotation class A
private annotation class B

private class C {
  @field: [
    A
    B
  ]
  val a: Int = 42
}

It would be great if ktlint was consistent with Android Studios formatting.

  • ktlint: 0.47.1 (CLI)
  • Android Studio Dolphin | 2021.3.1 RC 1
    Editorconfig:
root = true

[*]
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 140
trim_trailing_whitespace = true
# noinspection EditorConfigKeyCorrectness
ktlint_disabled_rules = import-ordering, package-name, filename
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
@paul-dingemans paul-dingemans changed the title Annotation Formatting Inconsistent Annotation formatting conflicts with IntelliJ IDEA / Android Studio Sep 9, 2022
@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 Sep 9, 2022
@paul-dingemans paul-dingemans added this to the 0.48.0 milestone Sep 9, 2022
@paul-dingemans
Copy link
Collaborator

Reproduced with IntelliJ IDEA as well.

@paul-dingemans
Copy link
Collaborator

paul-dingemans commented Oct 24, 2022

I believe it would be better if this was fixed in the IntelliJ IDEA formatter for which I have created https://youtrack.jetbrains.com/issue/KTIJ-23398/Inconsistent-formatting-of-arrays which is marked as duplicate of
https://youtrack.jetbrains.com/issue/KTIJ-14859/Too-little-indentation-inside-the-brackets-in-multiple-annotations-with-the-same-target

For consistencies reason, I will (temporarily) align with current IntellI IDEA default formatting. Resolved by #1682

@paul-dingemans
Copy link
Collaborator

Closed by #1682

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants