Commit e548195fd5
Changed files (2)
lib
std
lib/std/zig/parser_test.zig
@@ -7,6 +7,15 @@ test "zig fmt: trailing comma in container declaration" {
\\const X = struct { foo: i32 align(4) = 1, bar: i32 align(4) = 2 };
\\
);
+ try testTransform(
+ \\const X = struct {
+ \\ foo: i32, bar: i8 };
+ ,
+ \\const X = struct {
+ \\ foo: i32, bar: i8
+ \\};
+ \\
+ );
}
test "zig fmt: trailing comma in fn parameter list" {
lib/std/zig/render.zig
@@ -1181,8 +1181,8 @@ fn renderExpression(
// Check if the first declaration and the { are on the same line
const src_has_newline = !tree.tokensOnSameLine(
+ container_decl.lbrace_token,
container_decl.fields_and_decls.at(0).*.firstToken(),
- container_decl.rbrace_token,
);
// We can only print all the elements in-line if all the