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

Version 1.1.0.51 does not format correctly for style "Kotlinlang" #493

Closed
kay-horst opened this issue Jul 9, 2024 · 9 comments
Closed

Comments

@kay-horst
Copy link

  • Reformat code, formerly formatted with "Kotlinlang"-style => formatting is changed
  • Apply Gradle Spotless plugin (./gradlew spotlessapply) => Formatting back to old (correct) state

Settings for the Spotless plugin:

    kotlin {
        target 'src/main/**/*.kt'
        ktfmt().kotlinlangStyle()
    }

The workaround mentioned in #486 did not work for me.

@darioseidl
Copy link

This was also reported here #490 and is supposedly fixed, but the fix is not released yet.

I'm hoping they release it soon, so that the IntelliJ plugin, gradle-ktfmt and ktfmt jar all result in the same formatting again.

@theovier
Copy link

Any news on a possible release for the mentioned fix? It's quite annoying to work around this.

@rock3r
Copy link
Contributor

rock3r commented Aug 15, 2024

https://github.com/facebook/ktfmt/releases/tag/v0.52 🎉

@rock3r
Copy link
Contributor

rock3r commented Aug 15, 2024

Ah no, release failed :(

@hick209
Copy link
Contributor

hick209 commented Aug 27, 2024

v0.52 is out now. Let us know if you still face the issues reported here

@hick209
Copy link
Contributor

hick209 commented Aug 27, 2024

Also make sure that spotless is using the same version of ktfmt that you are using in your IDE

@darioseidl
Copy link

darioseidl commented Aug 28, 2024

v0.52 is out now. Let us know if you still face the issues reported here

It works for me now: ktfmt 0.52, the IntelliJ plugin, and ktfmt-gradle 0.20.1 all produce the same result.

@kay-horst
Copy link
Author

kay-horst commented Aug 28, 2024

The plugin now adds commas after each last parameter of a method, if each parameter is on its own line:

class Foo(
    private val value1: String,
    private val value2: String,
    private val value3: String,
    private val value3: String
) {

becomes

class Foo(
    private val value1: String,
    private val value2: String,
    private val value3: String,
    private val value3: String,
) {

It was not the case before.

Is this standard behaviour?

@hick209
Copy link
Contributor

hick209 commented Aug 28, 2024

@kay-horst it is as now it handles trailing lambdas for the kotlinlang style (see #442)

@hick209 hick209 closed this as completed Aug 28, 2024
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