Maybe a longshot but is it anyway possible in ktfm...
# ktfmt
a
Maybe a longshot but is it anyway possible in ktfmt to not keep chained methods on single line (when under 100 chars)? As in always keep newlines/put method chains with line breaks. This doesn't work too well for modifiers in compose for us
j
I have used
//
as workaround with multiple
?:
. Maybe it works with methods chain
g
Pretty sure it does. I still only use comments for that as rarely as possible, because it introduces visual clutter. In general, I'd advise against doing that, because it kind of defeats the purpose of a deterministic formatter... I'd like to be the formatter the source of truth and not have devs argue about linebreaks. (The formatter for Dart does an extremely good job there, I'd love ktfmt to be a bit more like dartfmt, but imo it's by far the best option for kotlin btw) So if I were you I'd probably open a feature request on GitHub (which I'd not expect to be implemented anytime soon) and use this workaround if I really really cannot bear the readability of a section of code.
a
I've found that it only line breaks on chains if the chain is longer than 100chars otherwise it keeps the chain on the single line if it fits and can't get it to work otherwise with any of the formatting styles (that can be changed). And yeah totally get the deterministic argument and ig was asking if there was a way to make that part of the behiavor for the deterministic style so that it's the case for all chain methods and not just some cases where it may introduce inconsistencies
g
For that case I fear you're stuck with a feature request... There are different styles to choose from, but I don't think any of them treats call chains differently
👍 2
a
Yeah that's what I imagined but was wondering if anyone got it working some other way. Cool, thanks for the info 🙂