Skip to content

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

@tx46

Description

@tx46
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterIssues related to code formatting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions