Commit 837cd748a8

Isaac Freund <ifreund@ifreund.xyz>
2021-02-08 13:42:02
zig fmt: fix block lbrace indent
1 parent aaf13a2
Changed files (2)
lib/std/zig/parser_test.zig
@@ -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" {
lib/std/zig/render.zig
@@ -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)),