| author | |
| committer | |
| log | 3cafb9655a754743da695af41ef635b79d066127 |
| tree | 50b2820164a9ce5650073ac58f88ce3ca32c880e |
| parent | ab6317d32bdc004e50cc4750ba9a89c9d81e05df |
2 files changed, 10 insertions(+), 4 deletions(-)
lib/std/zig/parser_test.zig+10-1| ... | @@ -2230,6 +2230,10 @@ test "zig fmt: switch cases trailing comma" { | ... | @@ -2230,6 +2230,10 @@ test "zig fmt: switch cases trailing comma" { |
| 2230 | \\ 1,2,3 => {}, | 2230 | \\ 1,2,3 => {}, |
| 2231 | \\ 4,5, => {}, | 2231 | \\ 4,5, => {}, |
| 2232 | \\ 6... 8, => {}, | 2232 | \\ 6... 8, => {}, |
| 2233 | \\ 9 ... | ||
| 2234 | \\ 10 => {}, | ||
| 2235 | \\ 11 => {}, | ||
| 2236 | \\ 12, => {}, | ||
| 2233 | \\ else => {}, | 2237 | \\ else => {}, |
| 2234 | \\ } | 2238 | \\ } |
| 2235 | \\} | 2239 | \\} |
| ... | @@ -2240,7 +2244,12 @@ test "zig fmt: switch cases trailing comma" { | ... | @@ -2240,7 +2244,12 @@ test "zig fmt: switch cases trailing comma" { |
| 2240 | \\ 4, | 2244 | \\ 4, |
| 2241 | \\ 5, | 2245 | \\ 5, |
| 2242 | \\ => {}, | 2246 | \\ => {}, |
| 2243 | \\ 6...8 => {}, | 2247 | \\ 6...8, |
| 2248 | \\ => {}, | ||
| 2249 | \\ 9...10 => {}, | ||
| 2250 | \\ 11 => {}, | ||
| 2251 | \\ 12, | ||
| 2252 | \\ => {}, | ||
| 2244 | \\ else => {}, | 2253 | \\ else => {}, |
| 2245 | \\ } | 2254 | \\ } |
| 2246 | \\} | 2255 | \\} |
lib/std/zig/render.zig-3| ... | @@ -1894,9 +1894,6 @@ fn renderSwitchCase( | ... | @@ -1894,9 +1894,6 @@ fn renderSwitchCase( |
| 1894 | // Render everything before the arrow | 1894 | // Render everything before the arrow |
| 1895 | if (switch_case.ast.values.len == 0) { | 1895 | if (switch_case.ast.values.len == 0) { |
| 1896 | try renderToken(r, switch_case.ast.arrow_token - 1, .space); // else keyword | 1896 | try renderToken(r, switch_case.ast.arrow_token - 1, .space); // else keyword |
| 1897 | } else if (switch_case.ast.values.len == 1 and !has_comment_before_arrow) { | ||
| 1898 | // render on one line and drop the trailing comma if any | ||
| 1899 | try renderExpression(r, switch_case.ast.values[0], .space); | ||
| 1900 | } else if (trailing_comma or has_comment_before_arrow) { | 1897 | } else if (trailing_comma or has_comment_before_arrow) { |
| 1901 | // Render each value on a new line | 1898 | // Render each value on a new line |
| 1902 | try renderExpressions(r, switch_case.ast.values, .comma); | 1899 | try renderExpressions(r, switch_case.ast.values, .comma); |