Skip to content

Commit f5f45b6

Browse files
add 'merge case branches' code action
1 parent 80644ae commit f5f45b6

15 files changed

+1618
-1
lines changed

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
from 1.13 has been extended to int segments!
9999
Aside from the various performance improvements, this allows the compiler to
100100
mark more branches as unreachable.
101+
101102
```gleam
102103
case bits {
103104
<<"a">> -> 0
@@ -111,6 +112,7 @@
111112
_ -> 99
112113
}
113114
```
115+
114116
([fruno](https://github.com/fruno-bulax/))
115117

116118
### Build tool
@@ -178,6 +180,31 @@
178180

179181
### Language server
180182

183+
- The language server can now offer a code action to merge consecutive case
184+
branches with the same body. For example:
185+
186+
```gleam
187+
case user {
188+
Admin(name:, ..) -> todo
189+
//^^^^^^^^^^^^^^^^^^^^^^^^
190+
Guest(name:, ..) -> todo
191+
//^^^^^^^^^^^^^^^^ Selecting these two branches you can
192+
// trigger the "Merge case branches" code action
193+
_ -> todo
194+
}
195+
```
196+
197+
Triggering the code action would result in the following code:
198+
199+
```gleam
200+
case user {
201+
Admin(name:, ..) | Guest(name:, ..) -> todo
202+
_ -> todo
203+
}
204+
```
205+
206+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
207+
181208
- The "inline variable" code action can now trigger when used over the let
182209
keyword of a variable to inline.
183210
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

0 commit comments

Comments
 (0)