https://kotlinlang.org logo
#getting-started
Title
# getting-started
u

ursus

09/06/2023, 2:49 PM
Is formatting changed in 1.9 or why is it adding a empty line before
else
in
when
?
v

Vampire

09/06/2023, 2:53 PM
Probably because your other branch is multi-line
u

ursus

09/06/2023, 2:53 PM
what other branch
v

Vampire

09/06/2023, 2:54 PM
The one with the two
is
conditions
u

ursus

09/06/2023, 2:54 PM
oh
okay you're right, my bad
but it's new regardless
okay not so fast 😄
no compoound condition
v

Vampire

09/06/2023, 2:56 PM
No, but still multi-line
u

ursus

09/06/2023, 2:57 PM
thats a very odd rule
either new line them all, not just else - or none at all
v

Vampire

09/06/2023, 2:58 PM
🤷‍♂️
From https://kotlinlang.org/docs/coding-conventions.html#control-flow-statements:
In a
when
statement, if a branch is more than a single line, consider separating it from adjacent case blocks with a blank line:
u

ursus

09/06/2023, 3:00 PM
fine. but the asymetricity of the whole thing is then just ugly ..if one is multiline then newline them all, regardless
okay thank you!
👌 1
v

Vampire

09/06/2023, 3:02 PM
Well, don't complain to me, but to the Kotlin team @ JetBrains. 🙂
😄 2
a

ascii

09/06/2023, 3:36 PM
This is a bug. Even if you set min lines to 0, formatting forces it to 1 new line.
I don't know if this has already been reported on YouTrack
v

Vampire

09/06/2023, 3:36 PM
min != max
😄
And that setting is about when branches with braces, not about multi-line when branches
a

ascii

09/06/2023, 3:39 PM
True, I misread. @ursus you could turn this off then:
🔥 2
u

ursus

02/19/2024, 7:08 PM
btw how does changing the setting relate to the official formatting set by the
gradle.properties
? (
kotlin.code.style=official
)
2 Views