Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndentationRule inserting unnecessary line break after assignment followed by any continuation #368

Closed
shashachu opened this issue Apr 4, 2019 · 1 comment · Fixed by #387
Assignees
Labels
Milestone

Comments

@shashachu
Copy link
Contributor

shashachu commented Apr 4, 2019

$ echo $'fun test() {
    val variable = first
        ?: second
}' > test.kt

$ ./ktlint -F --experimental test.kt

Expected:

fun test() {
    val variable = first
        ?: second
}

Actual:

fun test() {
    val variable =
        first
            ?: second
}

Seems to have something to do with the elvis operator; I haven't gotten it to break otherwise. Also works fine if the elvis operator is on the same line. Also,

fun test() {
    val variable = first
        second
}

produces

fun test() {
    val variable = first
    second
}

as expected.

@shashachu shashachu changed the title IndentationRule inserting unnecessary line break after assignment followed by elvis operator IndentationRule inserting unnecessary line break after assignment followed by any continuation Apr 8, 2019
@shashachu
Copy link
Contributor Author

Also occurs with:

$ echo $'fun test() {
    val variable = first
        ?: second
}' > test.kt

$ ./ktlint -F --experimental test.kt

Output

fun test() {
    val variable =
        first
            .function()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant