Hey everyone! I am testing `ktfmt` on our code-bas...
# ktfmt
d
Hey everyone! I am testing
ktfmt
on our code-bases with the
kotlinLangStyle()
(with the corresponding full
.editorconfig
from the
docs/
directory). I observe some strange formatting as soon as I put a fluent call after a trailing lambda:
Copy code
private fun someFunction1(): Flow<String> =
    callbackFlow {
            // ...
            send("Hello")
            // ...
        }
        .flowOn(<http://Dispatchers.IO|Dispatchers.IO>)

private fun someFunction2(): Flow<String> = callbackFlow {
    // ...
    send("Hello")
    // ...
}
Is this expected or a bug?
y
I reported this somewhat recently https://github.com/facebook/ktfmt/issues/589 It seems like it's intended, and the impact is large enough that maybe they don't want to change it. You independently reporting it is good evidence, though, that it is surprising behaviour
d
I see. Thanks for the issue link, I missed it while searching. I hope this will be fixed anyway. Because the non-matching indent on braces (even more evident when you have the indent guides in the IDE) are not reasonable IMO and will be enough for me to have a strike in my team. 😛
❤️ 2
I will pause our migration until this is resolved.
p
We've brushed it off under the rug of "but at least we don't have to worry about formatting any more" (along with a single-line lambda with only a return statement being forced as multi-line) but it still irks me slightly whenever I spot it.
❤️ 2
j
The inconsistency with the ide is certainly a bug if ktfmt is going to be the official formatter for kotlin. Either the ide indent guides should be updated to work with this formatting or the ktfmt formatting should change.
d
I would argue that this is a formatter bug because developers that use other IDEs (like VSCode or vim-like editors) often have key combinations to navigate the indent structures.