ktfmt
ktfmt copied to clipboard
Indent is inconsistent when lambda is qualified vs not.
Actual Behavior
val fn = launch {
doThing()
doAnother()
}
val fn =
scope.launch {
doThing()
doAnother()
}
Expected Behavior
val fn = launch {
doThing()
doAnother()
}
val fn = scope.launch {
doThing()
doAnother()
}
The issue is that lambdaOrScopingFunction and processLambdaOrScopingFunction do not handle dot qualified lambdas.
May need to refactor emitQualifiedExpression so that it only emits the selector expression, and returns the trailing lambda to the caller so that it can be emitted at a shallower syntactic block. Then we can call emitQualifiedExpression in processLambdaOrScopingFunction.
Agreed, and I like the "expected behavior". The "scoping function formatting" was a bit of a stopgap, because I didn't know how things should look like if the "first line" (e.g., val fn = scope.launch {) doesn't fit in one line.
Seems that we should have
val fn =
scope.launch {
doThing()
doAnother()
}
in that case, but GJF doesn't support this (https://github.com/google/google-java-format/issues/556)
What did you have in mind?
Behavior of v0.47
val fn = launch {
doThing()
doAnother()
}
val fn =
scope.launch {
doThing()
doAnother()
}
This is not something we plan to work anytime in the future here, but we'd welcome PRs as long as they don't regress other areas