gleam-lang/gleam

"Split alternative pattern" code action

Open

#4856 aperta il 16 ago 2025

Vedi su GitHub
 (6 commenti) (5 reazioni) (0 assegnatari)Rust (960 fork)batch import
help wanted

Metriche repository

Star
 (21.417 star)
Metriche merge PR
 (Merge medio 10g 19h) (69 PR mergiate in 30 g)

Descrizione

Sometimes code starts out as dealing with 2 patterns in the same way, but then later, something different has to happen for one or all of the cases. It could be nice if the language server provided a code action to split an alternative pattern into individual pattern matches.

Before:

case next() {
  Ok(response) -> response
  Error(MissingAccessToken) | Error(MissingRefreshToken) -> unauthorized()
  //  ^ split alternative patterns
}

After:

case next() {
  Ok(response) -> response
  Error(MissingAccessToken) -> unauthorized()
  Error(MissingRefreshToken) -> unauthorized()
}

To consider:

  • split The pattern on the selected pipe; That would make it more flexible, but would require more clicks to fully split a pattern.
  • Split out only the currently hovered alternative, leaving the rest in place

~ 💜

Guida contributor