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
}
207
};
208
209
-
const InnerFmtOptions = struct {
210
skip_type_name: bool = !default_options.show_type_names,
211
};
212
···
426
run: *const Runtime,
427
value: anytype,
428
) !void {
0
0
0
0
0
0
429
const next_ctx = Context{
430
.depth = ctx.depth + 1,
431
.exited_comptime = ctx.exited_comptime,
···
520
521
if (ctx.options.ptr_slice_inline) try arrayOpen(ctx, run);
522
0
523
for (value, 0..) |val, idx| {
0
0
524
indent(
525
next_ctx,
526
next_ctx.options.ptr_slice_inline,
···
541
run.resetColor();
542
543
try innerFmt(ptr.child, next_ctx, run, val, .{ .skip_type_name = true });
0
0
0
0
0
0
0
544
}
545
546
if (ctx.options.ptr_slice_inline) try arrayClose(ctx, run);
···
206
}
207
};
208
209
+
pub const InnerFmtOptions = struct {
210
skip_type_name: bool = !default_options.show_type_names,
211
};
212
···
426
run: *const Runtime,
427
value: anytype,
428
) !void {
429
+
if (arr.len == 0) {
430
+
try run.write(ctx.options.theme.array_open);
431
+
try run.write(ctx.options.theme.array_close);
432
+
return;
433
+
}
434
+
435
const next_ctx = Context{
436
.depth = ctx.depth + 1,
437
.exited_comptime = ctx.exited_comptime,
···
526
527
if (ctx.options.ptr_slice_inline) try arrayOpen(ctx, run);
528
529
+
var count: usize = 0;
530
for (value, 0..) |val, idx| {
531
+
count += 1;
532
+
533
indent(
534
next_ctx,
535
next_ctx.options.ptr_slice_inline,
···
550
run.resetColor();
551
552
try innerFmt(ptr.child, next_ctx, run, val, .{ .skip_type_name = true });
553
+
}
554
+
555
+
if (count == 0) {
556
+
run.setColor(ctx, .dim);
557
+
try run.write(ctx.options.theme.array_open);
558
+
try run.write(ctx.options.theme.array_close);
559
+
run.resetColor();
560
}
561
562
if (ctx.options.ptr_slice_inline) try arrayClose(ctx, run);