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

Wrong formatting in case expressions in presence of a long comment #3140

Closed
GioeleBucci opened this issue May 15, 2024 · 1 comment · Fixed by #3151
Closed

Wrong formatting in case expressions in presence of a long comment #3140

GioeleBucci opened this issue May 15, 2024 · 1 comment · Fixed by #3151
Labels
bug Something isn't working help wanted Contributions encouraged priority:medium

Comments

@GioeleBucci
Copy link

I noticed a weird behaviour when commenting a case with multiple patterns and pointed it out to @giacomocavalieri to assure it wasn't intended behaviour.

Here's an example:

fn foo(a: Int, b: Int) -> Bool {
  case a, b {
    // a very long comment a very long comment a very long comment a very long comment
    1, 2 -> True
    _, _ -> False
  }
}

After the formatting, the code above becomes the following:

fn foo(a: Int, b: Int) -> Bool {
  case a, b {
    // a very long comment a very long comment a very long comment a very long comment
    1, 2
    -> True
    _, _ -> False
  }
}

Such behaviour happens only when the comment is quite long (i suppose > 80 characters?) and in case of a shorter one the formatter works as expected.

fn foo(a: Int, b: Int) -> Bool {
  case a, b {
    // a not quite long comment
    1, 2 -> True
    _, _ -> False
  }
}

Version info

OS: Windows 11
gleam 1.1.0
rebar 3.22.1 on Erlang/OTP 25 Erts 13.2.2.2

Logs

link to pastebin

@GioeleBucci GioeleBucci added the bug Something isn't working label May 15, 2024
@lpil
Copy link
Member

lpil commented May 15, 2024

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Contributions encouraged priority:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants