zig fmt: fix block lbrace indent

This commit is contained in:
Isaac Freund
2021-02-08 13:42:02 +01:00
committed by Andrew Kelley
parent aaf13a2bb3
commit 837cd748a8
2 changed files with 23 additions and 23 deletions

View File

@@ -2703,28 +2703,28 @@ test "zig fmt: catch" {
);
}
//test "zig fmt: blocks" {
// try testCanonical(
// \\test "blocks" {
// \\ {
// \\ const a = 0;
// \\ const b = 0;
// \\ }
// \\
// \\ blk: {
// \\ const a = 0;
// \\ const b = 0;
// \\ }
// \\
// \\ const r = blk: {
// \\ const a = 0;
// \\ const b = 0;
// \\ };
// \\}
// \\
// );
//}
//
test "zig fmt: blocks" {
try testCanonical(
\\test "blocks" {
\\ {
\\ const a = 0;
\\ const b = 0;
\\ }
\\
\\ blk: {
\\ const a = 0;
\\ const b = 0;
\\ }
\\
\\ const r = blk: {
\\ const a = 0;
\\ const b = 0;
\\ };
\\}
\\
);
}
//test "zig fmt: switch" {
// try testCanonical(
// \\test "switch" {

View File

@@ -1768,8 +1768,8 @@ fn renderBlock(
return renderToken(ais, tree, lbrace + 1, space); // rbrace
}
ais.pushIndent();
try renderToken(ais, tree, lbrace, .Newline);
ais.pushIndent();
for (statements) |stmt, i| {
switch (node_tags[stmt]) {
.GlobalVarDecl => try renderVarDecl(ais, tree, tree.globalVarDecl(stmt)),