-
Notifications
You must be signed in to change notification settings - Fork 503
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
auto-indent bodies of multiline strings with .trimIndent() #925
Comments
Also note that this isn't a super high priority for us |
Quite specific case, probably Ktlint should while formatting move multiline string content as well when it uses @romtsn what do you think about this? |
I am not sure we'd like to introduce that, as the idea of |
Imho ktlint should handle correctly this specific edge-case - on formatting raw string if it ends with |
I might be misremembering, but I think we recently reverted some code that would touch the contents of raw strings for the same reasoning that @romtsn said - it's a raw string so we assume we should leave the contents alone. |
In PR this is resolved. Indentation of multiline strings is improved. |
@paul-dingemans made some improvements to string templates, but we aren't going to touch the contents of them. Perhaps, this would make a good third-party rule or in a new-to-be-defined-upcoming-contrib-ruleset |
Actually I have developed such a rule a while ago. I can however not release it until #1230 has been merged. |
…al` code style This rule forces multiline string templates which are post-fixed with `.trimIndent()` to be formatted consistently. The opening and closing `"""` are placed on separate lines and the indentation of the content of the template is aligned with the `"""`. Closes #925
We had some code that looks like this:
and we asked ktlint to format it and ktlint correctly pointed out that the quotation marks in the multiline string need to be deindented by 4 spaces. However, ktlint didn't deindent the body of the string too
Observed Behavior
ktlint formatted this code into this:
Expected Behavior
We would like ktlint to notice the
.trimIndent()
that follows the multiline string, and then deindent the body of the string to match, to get:Your Environment
We're seeing this when upgrading from ktlint 0.36.0 to 0.39.0
The code in question: https://android-review.googlesource.com/c/platform/frameworks/support/+/1431946/1/buildSrc/src/main/kotlin/androidx/build/Release.kt#92
The text was updated successfully, but these errors were encountered: