avh4/elm-format

Formatting produces invalid code when comment is in pattern of a case expression

jfmengels opened this issue · 1 comments

When introducing a comment in a pattern in a case expression, elm-format will reformat it like the following:

value =
    case x of
        A
            -- comment
            ()
        ->
            1

        B
        -- comment
        ->
            1

Here, both branches are considered to be a syntax error. The -> needs to be indented by at least one space (or move to after the () in the first pattern).
(more complete example: https://ellie-app.com/rHrcvrMP88Ha1)

avh4 commented

Ah thanks! I think that's been in there for at least 2 years before anyone noticed it 😆 This is something #36 would have caught, but it's sadly been too much of a mess to get implemented easily.

I can probably get to this over the summer. Also PR is welcome.