-
Notifications
You must be signed in to change notification settings - Fork 506
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
Raw strings forced on a separate line by indent rule #711
Comments
This behavior is especially annoying when using single-line raw strings, e.g. as function arguments. (Using named parameters makes it even worse.) data class Example(val string: String)
val e = Example(string = """a"b"c""") The above code snippet is auto-formatted by ktlint into the following. data class Example(val string: String)
val e = Example(string =
"""a"b"c""") However, this is not valid according to ktlint, so it also includes some errors.
Running ktlint with auto formatting again then gives the following. data class Person(val name: String)
val p = Person(
name =
"""a"b"c"""
) This is quite a lot worse than the initial code example, especially if we add more arguments (which may even contain raw strings). |
I was planning to work on this, if nobody has already started. |
@MehWhatever would be awesome, most likely it's just commenting out these lines: Lines 336 to 339 in 94b62e2
But I'm not sure, definitely needs some testing. |
This isn't the most recent version available, but the most recent version has pinterest/ktlint#711 which causes raw strings to be formatted weirdly.
Adding another example to this issue. The following line: val html = """<span style="color:red;">my span</span>""" Gets reformatted by ktlint v0.37.2 to this: val html =
"""<span style="color:red;">my span</span>""" |
KtLint 0.36.0
Raw strings don't seem to play well with indent experimental rule. For example this:
reports an error:
[experimental:indent] Missing newline after "="
This (weird) formatting:
reports wrong indentation for the first
"""
, however this:is automatically reformatted by IntellIJ to the previous variant (with first
"""
not indented)The text was updated successfully, but these errors were encountered: