Ktlint: Formatter never satisfied with raw string indentation

Created on 7 Jan 2020  路  3Comments  路  Source: pinterest/ktlint

Source code

val y = 5
val x =
  """
    $y
  """.trimIndent()

Expected behavior

ktlint --experimental --format is a no-op after at most one invocation.

Actual behavior

ktlint always adds 6 additional space characters in front of $y, i.e. running ktlint n times will prepend 6*n spaces to $y.

bug

Most helpful comment

Thanks. We're targeting a 0.37.1 release ASAP to fix this and possibly 1 or 2 more bugs in 0.37.0.

All 3 comments

I can confirm this bug.

I tried to disable the rule for the whole file by putting

/* ktlint-disable experimental:indent */

at the start of the file where I use raw strings since the IndentationRule docs state

"all or nothing" (currently, rule can only be disabled for an entire file)

But no luck. Ktlint still complains. How can I disable this rule for a file then? .)

It seems this bug made it into non-experimental mode as part of 0.37.0. We use raw strings often and it inhibits our ability to upgrade.

Thanks. We're targeting a 0.37.1 release ASAP to fix this and possibly 1 or 2 more bugs in 0.37.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pkubowicz picture pkubowicz  路  4Comments

DanteAndroid picture DanteAndroid  路  3Comments

nokite picture nokite  路  4Comments

impatient picture impatient  路  5Comments

filipedelimabrito picture filipedelimabrito  路  3Comments