Open maxdeviant opened 6 months ago
Thanks
It looks like this was an intentional choice https://github.com/gleam-lang/gleam/blob/main/compiler-core/src/format.rs#L1762-L1775 with the justification being in https://github.com/gleam-lang/gleam/issues/2239
It looks like this was an intentional choice https://github.com/gleam-lang/gleam/blob/main/compiler-core/src/format.rs#L1762-L1775 with the justification being in #2239
The above formatting doesn't seem to align with what is shown in the linked issue.
Note how in my example there is no indentation of the arm, which definitely seems wrong.
Ahhh my bad, i over focused in the arrow location. I'll try to take a look at this tomorrow night
Bad news! The fix actually introduced another bug that resulted in a more common case being formatted badly. So we should reopen this and try and find a different way to format this code examples: the thing that I can't figure out is how to keep the arrow on the same line as the last clause.
Here's some test cases we should keep in mind:
fn test_1() {
case a, b, c {
_ignored, _ignored, _ignored
| _ignored, _ignored, _ignored
| _ignored, _ignored, _ignored
-> True
}
}
fn test_2() {
case a, b, c {
_, _, _
| _, _, _
| this_is_long_and_is_going_to_split_on_multiple,
lines,
and_force_the_arrow_to_break
-> True
}
}
fn test_3() {
case a, b, c {
_, _, _
| this_is_long_and_is_going_to_split_on_multiple,
lines,
and_force_the_alternative_to_break
| _, _, _
-> True
}
}
For the time being I'll revert this fix so that RC-1.2 doesn't have the bug introduced by this fix
While working on https://github.com/massivefermion/birl/pull/24 I noticed some weird formatting applied by
gleam format
in Gleam v1.1.I pointed it out to @giacomocavalieri and he asked me to open an issue here.
Here is a slightly more minimized reproduction (repo):
I would expect something more like this:
Version Info
Gleam Logs