rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

long matches in switch statements mutline-formats records (but moving to next line is better)

Open tx46 opened this issue 2 months ago • 0 comments

switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" => {a: 1, b: 2, c: 3}
}

formats to:

switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" => {
    a: 1,
    b: 2,
    c: 3,
  }
}

but this would likely be better:

switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" =>
  {a: 1, b: 2, c: 3}
}

the formatter won't let you do that, but splits it to multiplie lines again. workaround i use is to add a comment:

switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" => //
  {a: 1, b: 2, c: 3}
}

minor, but it's still an annoyance

tx46 avatar Oct 14 '25 02:10 tx46