Ktfmt intellij plugin does not account for line ranges nor declares Feature.FORMAT_FRAGMENTS in it's KtfmtFormattingService (see FormattingServiceUtil.findService).
As a result, using "reformat before commit", formatting a selected portion of the code or other partial reformatting from the IDE result in formatting that do not comply with Ktfmt, leading to inconsistent states and need for manual reformatting of our repo every once in a while.
Git hooks or full reformat before commit are a workaround but is not convenient (breaks committing only a part of a file's changes to VCS) and requires extra setup and computation.
Reproduction sample:
- Committing with "Reformat code" commit check leads to the formatting below
- Reformatting with Ktfmt changes indents and puts the first
padding in the same line as Modifier
private fun MyComposeFunction() {
Function(
modifier =
Modifier
.padding(vertical = someVerticalPadding())
.padding(vertical = someVerticalPadding())
)
}
fun Function(
modifier: Any,
): Unit = TODO()
fun someVerticalPadding(): Any = TODO()
interface Modifier {
fun padding(vertical: Any): Modifier = TODO()
companion object : Modifier
}
Ktfmt intellij plugin does not account for line ranges nor declares
Feature.FORMAT_FRAGMENTSin it'sKtfmtFormattingService(see FormattingServiceUtil.findService).As a result, using "reformat before commit", formatting a selected portion of the code or other partial reformatting from the IDE result in formatting that do not comply with Ktfmt, leading to inconsistent states and need for manual reformatting of our repo every once in a while.
Git hooks or full reformat before commit are a workaround but is not convenient (breaks committing only a part of a file's changes to VCS) and requires extra setup and computation.
Reproduction sample:
paddingin the same line asModifier