Skip to content

Commit 653dd4d

Browse files
committed
Force linebreaks between multiple expressions in unit switch case
1 parent 7c11224 commit 653dd4d

File tree

3 files changed

+55
-34
lines changed

3 files changed

+55
-34
lines changed

corpus/unit.spicy

+25-17
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ switch {
3131
};
3232
};
3333

34-
type X = unit {
35-
switch (True) {
36-
* -> {
37-
switch (True) {
38-
* -> x: uint8;
39-
};
40-
}
41-
};
42-
};
43-
4434
type X = unit{
4535
on %init {}
4636
b: uint8 {print $$;}
@@ -55,13 +45,6 @@ type X = unit {
5545
: uint8 if (True);
5646
};
5747

58-
public type X = unit {
59-
switch (1+1) {
60-
1 -> a : b"1";
61-
* -> : void;
62-
};
63-
};
64-
6548
type X = unit () {};
6649

6750
type X = unit (x: X) {};
@@ -113,6 +96,31 @@ type X = unit {
11396
# Bar.
11497
};
11598

99+
public type X = unit {
100+
switch (1+1) {
101+
1 -> a : b"1";
102+
* -> : void;
103+
};
104+
};
105+
106+
type X = unit {
107+
switch (True) {
108+
* -> {
109+
switch (True) {
110+
* -> x: uint8;
111+
};
112+
}
113+
};
114+
};
115+
116+
type X = unit(a: uint8) {
117+
switch (a) {
118+
1,
119+
2,
120+
3 -> : skip uint8;
121+
};
122+
};
123+
116124
# Sink syntax.
117125
public type X = unit {
118126
: bytes &eod -> self.data;

corpus/unit.spicy.expected

+25-17
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ type X = unit {
4040
};
4141
};
4242

43-
type X = unit {
44-
switch (True) {
45-
* -> {
46-
switch (True) {
47-
* -> x: uint8;
48-
};
49-
}
50-
};
51-
};
52-
5343
type X = unit {
5444
on %init {}
5545
b: uint8 {
@@ -66,13 +56,6 @@ type X = unit {
6656
: uint8 if(True);
6757
};
6858

69-
public type X = unit {
70-
switch (1 + 1) {
71-
1 -> a: b"1";
72-
* -> : void;
73-
};
74-
};
75-
7659
type X = unit {};
7760

7861
type X = unit(x: X) {};
@@ -136,6 +119,31 @@ type X = unit {
136119
# Bar.
137120
};
138121

122+
public type X = unit {
123+
switch (1 + 1) {
124+
1 -> a: b"1";
125+
* -> : void;
126+
};
127+
};
128+
129+
type X = unit {
130+
switch (True) {
131+
* -> {
132+
switch (True) {
133+
* -> x: uint8;
134+
};
135+
}
136+
};
137+
};
138+
139+
type X = unit(a: uint8) {
140+
switch (a) {
141+
1,
142+
2,
143+
3 -> : skip uint8;
144+
};
145+
};
146+
139147
# Sink syntax.
140148
public type X = unit {
141149
: bytes &eod -> self.data;

src/query.scm

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
"->" @prepend_space @append_space
9898
)
9999

100+
(unit_switch_case
101+
(expression)+
102+
(expression) @prepend_hardline
103+
)
104+
100105
(switch
101106
"switch" @append_space
102107
"(" (expression) ")" @append_space

0 commit comments

Comments
 (0)