Skip to content

Make "Add missing patterns" code action insert variants in order of definition. #5184

@fruno-bulax

Description

@fruno-bulax

Currently when using the "Add missing patterns" code action, the missing patterns are inserted in alphabetical order:

// The variants are defined as such:
type Wibble {
  B
  A
}

// Yet the code action yields:
case wibble {
  A -> todo
  B -> todo
}

In my opinion it would be better if they were added in the same order in which they are defined.
Right now I often find myself manually reordering them, as I group "related" variants together to make the code clearer.

According to Gears:

The "missing patterns" error was sorted alphabetically in order to make testing more deterministic. The "add missing patterns" code action takes data from that error, so it's sorted alphabetically

It seems like the easiest solution might be to order the change the ordering in the error. Do you think that is acceptable or should we laser-target the code action?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions encouraged

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions