authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-03 15:24:07+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-03 16:03:48-05:00
log1658becb6221f9ffdbfd653c5e295501ac338794
tree572a3a2c99d61dd924f6ecf55f303e155541b3dc
parent5504f155aa83c7fc9a3610b2dcd38d0c1fc3a0c9

fmt: Fix one more edge case in container formatting


2 files changed, 12 insertions(+), 0 deletions(-)

lib/std/zig/parser_test.zig+10
......@@ -7,6 +7,16 @@ test "zig fmt: trailing comma in container declaration" {
77 \\const X = struct { foo: i32 align(4) = 1, bar: i32 align(4) = 2 };
88 \\
99 );
10 try testCanonical(
11 \\test "" {
12 \\ comptime {
13 \\ const X = struct {
14 \\ x: i32
15 \\ };
16 \\ }
17 \\}
18 \\
19 );
1020 try testTransform(
1121 \\const X = struct {
1222 \\ foo: i32, bar: i8 };
lib/std/zig/render.zig+2
......@@ -1224,6 +1224,8 @@ fn renderExpression(
12241224 const space_after_decl: Space = if (it.peek() == null) .Newline else .Space;
12251225 try renderContainerDecl(allocator, stream, tree, new_indent, start_col, decl.*, space_after_decl);
12261226 }
1227
1228 try stream.writeByteNTimes(' ', indent);
12271229 } else {
12281230 // All the declarations on the same line
12291231 try renderToken(tree, stream, container_decl.lbrace_token, indent, start_col, .Space); // {