authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-03 11:43:48+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-03 11:49:42+01:00
loge6485282d36d58e24b812ee6dd76e97d25658dc6
treee4239c22d896ccc1540c4c27dd036860f7f5843f
parent7b375a1c4a88d7751bd2d5e713108a16df9cb103

Better logic for last-param rendering


2 files changed, 5 insertions(+), 10 deletions(-)

lib/std/zig/parser_test.zig+2-8
......@@ -29,14 +29,8 @@ test "zig fmt: c pointer type" {
2929test "zig fmt: builtin call with trailing comma" {
3030 try testCanonical(
3131 \\pub fn main() void {
32 \\ _ = @intToPtr(
33 \\ a,
34 \\ b,
35 \\ );
36 \\ _ = @ptrCast(
37 \\ a,
38 \\ b,
39 \\ );
32 \\ @breakpoint();
33 \\ _ = @boolToInt(a);
4034 \\ _ = @call(
4135 \\ a,
4236 \\ b,
lib/std/zig/render.zig+3-2
......@@ -1264,7 +1264,9 @@ fn renderExpression(
12641264 }
12651265
12661266 const src_params_trailing_comma = blk: {
1267 const maybe_comma = tree.prevToken(builtin_call.rparen_token);
1267 if (builtin_call.params.len < 2) break :blk false;
1268 const last_node = builtin_call.params.at(builtin_call.params.len - 1).*;
1269 const maybe_comma = tree.nextToken(last_node.lastToken());
12681270 break :blk tree.tokens.at(maybe_comma).id == .Comma;
12691271 };
12701272
......@@ -1277,7 +1279,6 @@ fn renderExpression(
12771279 var it = builtin_call.params.iterator(0);
12781280 while (it.next()) |param_node| {
12791281 try renderExpression(allocator, stream, tree, indent, start_col, param_node.*, Space.None);
1280 // try renderParamDecl(allocator, stream, tree, indent, start_col, param_node.*, Space.None);
12811282
12821283 if (it.peek() != null) {
12831284 const comma_token = tree.nextToken(param_node.*.lastToken());