Strange Kotlin autoformatting

已回答

I am using IntelliJ IDEA 2024.1.6 (Ultimate Edition). For Kotlin code style, I chose to use drafults from Kotlin Coding Conventions.

I start with this code:

fun rollThreeUnfairDice(minValue: Int, maxValue: Int): Int {
    return rollUnfairDie(minValue, maxValue) + rollUnfairDie(minValue, maxValue) + rollUnfairDie(minValue, maxValue)
}

When I do Code > Reformat Code, I get:

fun rollThreeUnfairDice(minValue: Int, maxValue: Int): Int {
    return rollUnfairDie(minValue, maxValue) + rollUnfairDie(
        minValue,
        maxValue
    ) + rollUnfairDie(minValue, maxValue)
}

If I reformat again (removing custom line breaks), I get:

fun rollThreeUnfairDice(minValue: Int, maxValue: Int): Int {
    return rollUnfairDie(minValue, maxValue) + rollUnfairDie(
        minValue, maxValue
    ) + rollUnfairDie(minValue, maxValue)
}

Is this working as intended? I expected the three calls to be formatted the same way.

0

Thank you! I failed to reproduce the problem. Can you attach your code style scheme - `Settings | Editor | Code Style | Kotlin | ⚙ | Export`?

0

请先登录再写评论。