fmt: Use left brace position instead of the right one

Fix a typo and add a test case.
This commit is contained in:
LemonBoy 2020-02-01 15:28:23 +01:00
parent f34abbf260
commit e548195fd5
2 changed files with 10 additions and 1 deletions

View File

@ -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" {

View File

@ -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