Skip to content

Commit f6fbc45

Browse files
fix(match): Indent match conditions (#2258)
1 parent f3a3385 commit f6fbc45

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/printer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2847,7 +2847,7 @@ function printNode(path, options, print) {
28472847
}, "arms");
28482848
return group([
28492849
"match (",
2850-
group([softline, indent(print("cond")), softline]),
2850+
group([indent([softline, print("cond")]), softline]),
28512851
") {",
28522852
group(indent([...arms])),
28532853
" ",

tests/match/__snapshots__/jsfmt.spec.js.snap

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ match ($a) {
6666
6767
};
6868
69+
match($really_really_really_really_really_really_really_really_long_variable_name) {
70+
default => null
71+
};
72+
6973
=====================================output=====================================
7074
<?php
7175
@@ -94,7 +98,7 @@ $a = match (true) {
9498
};
9599
96100
$nest = match (
97-
match ($a) {
101+
match ($a) {
98102
true => 1,
99103
false => 2
100104
}
@@ -148,6 +152,12 @@ match ($a) {
148152
"b" => 2
149153
};
150154
155+
match (
156+
$really_really_really_really_really_really_really_really_long_variable_name
157+
) {
158+
default => null
159+
};
160+
151161
================================================================================
152162
`;
153163

@@ -217,6 +227,10 @@ match ($a) {
217227
218228
};
219229
230+
match($really_really_really_really_really_really_really_really_long_variable_name) {
231+
default => null
232+
};
233+
220234
=====================================output=====================================
221235
<?php
222236
@@ -245,7 +259,7 @@ $a = match (true) {
245259
};
246260
247261
$nest = match (
248-
match ($a) {
262+
match ($a) {
249263
true => 1,
250264
false => 2,
251265
}
@@ -299,5 +313,11 @@ match ($a) {
299313
"b" => 2,
300314
};
301315
316+
match (
317+
$really_really_really_really_really_really_really_really_long_variable_name
318+
) {
319+
default => null,
320+
};
321+
302322
================================================================================
303323
`;

tests/match/match.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@
5555
'b' => 2
5656

5757
};
58+
59+
match($really_really_really_really_really_really_really_really_long_variable_name) {
60+
default => null
61+
};

0 commit comments

Comments
 (0)