Skip to content

Commit 808db93

Browse files
sin-ackianprime0509
authored andcommitted
zig_writer: Replace tabs with spaces when outputting
Ref: ziglang/zig#20885
1 parent f6a8e28 commit 808db93

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/zig_writer.zig

+8-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ pub fn ZigWriter(comptime Writer: type) type {
5757
const arg = @field(args, arg_fields[current_arg].name);
5858
const arg_type_info = @typeInfo(@TypeOf(arg));
5959
if (arg_type_info == .Pointer and arg_type_info.Pointer.size == .Slice and arg_type_info.Pointer.child == u8) {
60-
try w.out.print("{s}", .{arg});
60+
for (arg) |char| {
61+
switch (char) {
62+
// Zig is very tab-hostile, so we have to replace tabs with spaces.
63+
// This is most relevant when translating documentation.
64+
'\t' => try w.out.writeAll(" "),
65+
else => try w.out.writeByte(char),
66+
}
67+
}
6168
} else {
6269
try w.out.print("{}", .{arg});
6370
}

0 commit comments

Comments
 (0)