authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-01 15:28:23+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-01 15:28:23+01:00
loge548195fd5ddedb5b2d87ef4b396666917e6d9b6
tree674f54217636d2168e804558aa52734b095d618c
parentf34abbf2602c60a562988631de6a3dcbefbbb4cd

fmt: Use left brace position instead of the right one

Fix a typo and add a test case.

2 files changed, 10 insertions(+), 1 deletions(-)

lib/std/zig/parser_test.zig+9
......@@ -7,6 +7,15 @@ 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 testTransform(
11 \\const X = struct {
12 \\ foo: i32, bar: i8 };
13 ,
14 \\const X = struct {
15 \\ foo: i32, bar: i8
16 \\};
17 \\
18 );
1019}
1120
1221test "zig fmt: trailing comma in fn parameter list" {
lib/std/zig/render.zig+1-1
......@@ -1181,8 +1181,8 @@ fn renderExpression(
11811181
11821182 // Check if the first declaration and the { are on the same line
11831183 const src_has_newline = !tree.tokensOnSameLine(
1184 container_decl.lbrace_token,
11841185 container_decl.fields_and_decls.at(0).*.firstToken(),
1185 container_decl.rbrace_token,
11861186 );
11871187
11881188 // We can only print all the elements in-line if all the