gleam-lang/gleam

"Split alternative pattern" code action

Open

#4.856 geöffnet am 16. Aug. 2025

Auf GitHub ansehen
 (6 Kommentare) (5 Reaktionen) (0 zugewiesene Personen)Rust (960 Forks)batch import
help wanted

Repository-Metriken

Stars
 (21.417 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 10T 19h) (69 gemergte PRs in 30 T)

Beschreibung

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

~ 💜

Contributor Guide