tangled
alpha
login
or
join now
altagos.dev
/
pretty
0
fork
atom
A pretty printer for zig
zig
0
fork
atom
overview
issues
pulls
pipelines
print braces for empty arrays
altagos.dev
3 weeks ago
aa04716e
da8f80cb
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+17
-1
1 changed file
expand all
collapse all
unified
split
pretty.zig
+17
-1
pretty.zig
···
206
206
}
207
207
};
208
208
209
209
-
const InnerFmtOptions = struct {
209
209
+
pub const InnerFmtOptions = struct {
210
210
skip_type_name: bool = !default_options.show_type_names,
211
211
};
212
212
···
426
426
run: *const Runtime,
427
427
value: anytype,
428
428
) !void {
429
429
+
if (arr.len == 0) {
430
430
+
try run.write(ctx.options.theme.array_open);
431
431
+
try run.write(ctx.options.theme.array_close);
432
432
+
return;
433
433
+
}
434
434
+
429
435
const next_ctx = Context{
430
436
.depth = ctx.depth + 1,
431
437
.exited_comptime = ctx.exited_comptime,
···
520
526
521
527
if (ctx.options.ptr_slice_inline) try arrayOpen(ctx, run);
522
528
529
529
+
var count: usize = 0;
523
530
for (value, 0..) |val, idx| {
531
531
+
count += 1;
532
532
+
524
533
indent(
525
534
next_ctx,
526
535
next_ctx.options.ptr_slice_inline,
···
541
550
run.resetColor();
542
551
543
552
try innerFmt(ptr.child, next_ctx, run, val, .{ .skip_type_name = true });
553
553
+
}
554
554
+
555
555
+
if (count == 0) {
556
556
+
run.setColor(ctx, .dim);
557
557
+
try run.write(ctx.options.theme.array_open);
558
558
+
try run.write(ctx.options.theme.array_close);
559
559
+
run.resetColor();
544
560
}
545
561
546
562
if (ctx.options.ptr_slice_inline) try arrayClose(ctx, run);