-
Notifications
You must be signed in to change notification settings - Fork 80
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
Android Studio / IDEA plugin yields different results than running ktfmt #444
Comments
@greyhairredbear do you know if this is related to #420? |
I tried to format you code here and it fails due to the Could you revisit and share a piece of code where we could repro the issue? |
Unfortunately, not really. My original thought was that this might be because of different ktfmt versions, but according to the original post in the gradle plugin, this doesn't seem to be the case.
UPDATE: @hick209 of course, you are correct, the PS: @gino-m I suppose it would be helpful to also include the versions used in this post. |
Just FYI: When using #420, the code stays unchanged (regardless of the formatting) due to it not being valid Kotlin. After removing the
|
@hick209 So sorry, was moving too fast. That was Java - added a Kotlin example . @greyhairredbear The formatting in the above snippet was produced by Android Studio ktfmt plugin 1.1.0.47, the Gradle plugin |
@gino-m this might be related: cortinico/ktfmt-gradle#277 |
FYI: Just tried the new version of the plugin released last week and the code you mentioned
gets reformatted to the code produced by the gradle plugin
Seems to me this is not an issue anymore - probably has been fixed with #420. @gino-m could you verify that also is the case with the code you've mentioned, so we can close this? |
Confirmed, I upgraded to 1.1.0.49 and the outputs for this particular use case now match. There are still some differences, which I've tried to capture here: https://github.com/google/ground-android/pull/2456/commits The first run of the latest AS plugin across our codebase introduced many changes, most of which are not modified by running ktfmt via Gradle again. Subsequent commits demonstrate formatting which is changes by both entry points on each run, namely: google/ground-android@b9736a1 |
@gino-m did you also update the ktfmt-gradle to the newer version (0.18.0)? I suspect the intellij plugin is working correctly but your codebase was formatted incorrectly with the older Gradle plugin |
Good catch. I upgraded ktfmt-gradle to 0.18.0 and reformatted (google/ground-android@9dc9da5). Reformatting with AS ktfmt 1.1.0.49 still yields several diffs (google/ground-android@e6a4974), but subsequent runs of ktfmt-gradle only modify three files (google/ground-android@ea60727). Two of these changes get undone when running the AS plugin again (google/ground-android@ebe230e). At this point I would expect the diffs, if any, to be symmetrical, but running ktfmt-gradle again only modifies one file (google/ground-android@81371be). After that, subsequent runs fight over a single delta (google/ground-android@e26f8d9). Edit: Pasting screenshot here for convenience. Before = ktfmt-gradle 0.180, After = AS ktfmt 1.1.0.49: If that delta is resolved the formatting should be stable across both plugins after each is run several times. |
What is the output of the CLI? I ran |
Originally posted in cortinico/ktfmt-gradle#264
🐛 Describe the bug
Formatting with the Android Studio ktfmt plugin produces a different result than ktfmtFormat via Gradle and https://facebook.github.io/ktfmt/.
./gradlew ktfmtFormat
target (or trigger via IDE) provided by Gradle plugincom.ncorti.ktfmt.gradle
version 0.17.0:"Format code" using Android Studio ktfmt plugin 1.1.0.47:
More deltas can be found in https://github.com/google/ground-android/pull/2412/files. Base files are formatted via the Gradle plugin, modified files with AS plugin.
✅ Expected behavior
Both formatters produce the same result.
@cortinico @cgrushko @sufyanAbbasi @shobhitagarwal1612 FYI
The text was updated successfully, but these errors were encountered: