authorgravatar for shritesh@shritesh.comShritesh Bhattarai <shritesh@shritesh.com> 2019-03-31 21:28:28-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-31 22:33:32-04:00
logd6455008830eff433a14c5eff6094f2f5ba9991d
tree4ea2109b54cc4a0800e6aa685913d1ad78001c2f
parent0563e8e1d4181a2707a1898941ccf59d974bc835

fmt: fix first line comment indent in struct init


2 files changed, 16 insertions(+), 3 deletions(-)

std/zig/parser_test.zig+13
......@@ -1027,6 +1027,19 @@ test "zig fmt: line comments in struct initializer" {
10271027 );
10281028}
10291029
1030test "zig fmt: first line comment in struct initializer" {
1031 try testCanonical(
1032 \\pub async fn acquire(self: *Self) HeldLock {
1033 \\ return HeldLock{
1034 \\ // TODO guaranteed allocation elision
1035 \\ .held = await (async self.lock.acquire() catch unreachable),
1036 \\ .value = &self.private_data,
1037 \\ };
1038 \\}
1039 \\
1040 );
1041}
1042
10301043test "zig fmt: doc comments before struct field" {
10311044 try testCanonical(
10321045 \\pub const Allocator = struct {
std/zig/render.zig+3-3
......@@ -658,11 +658,11 @@ fn renderExpression(
658658 return renderToken(tree, stream, suffix_op.rtoken, indent, start_col, space);
659659 }
660660
661 try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);
662 try renderToken(tree, stream, lbrace, indent, start_col, Space.Newline);
663
664661 const new_indent = indent + indent_delta;
665662
663 try renderExpression(allocator, stream, tree, new_indent, start_col, suffix_op.lhs, Space.None);
664 try renderToken(tree, stream, lbrace, new_indent, start_col, Space.Newline);
665
666666 var it = field_inits.iterator(0);
667667 while (it.next()) |field_init| {
668668 try stream.writeByteNTimes(' ', new_indent);