Skip to content

Instantly share code, notes, and snippets.

@Des-Nerger
Created August 31, 2024 01:43
Show Gist options
  • Save Des-Nerger/bbd9b85922f60c74e48fe58f2087ef20 to your computer and use it in GitHub Desktop.
Save Des-Nerger/bbd9b85922f60c74e48fe58f2087ef20 to your computer and use it in GitHub Desktop.
--- lib/std/zig/render.zig 2024-06-10 01:59:43.000000000 +1000
+++ lib/std/zig/render_modified.zig 2024-06-14 16:49:09.134802136 +1000
@@ -1,4 +1,5 @@
const std = @import("../std.zig");
+const divExact = std.math.divExact;
const assert = std.debug.assert;
const mem = std.mem;
const Allocator = std.mem.Allocator;
@@ -7,7 +8,7 @@
const Token = std.zig.Token;
const primitives = std.zig.primitives;
-const indent_delta = 4;
+const indent_delta = 2;
const asm_indent_delta = 2;
pub const Error = Ast.RenderError;
@@ -3216,7 +3217,7 @@
fn writeFixingWhitespace(writer: std.ArrayList(u8).Writer, slice: []const u8) Error!void {
for (slice) |byte| switch (byte) {
- '\t' => try writer.writeAll(" " ** 4),
+ // '\t' => try writer.writeAll(" " ** 4),
'\r' => {},
else => try writer.writeByte(byte),
};
@@ -3443,7 +3444,10 @@
const current_indent = self.currentIndent();
if (self.current_line_empty and current_indent > 0) {
if (self.disabled_offset == null) {
- try self.underlying_writer.writeByteNTimes(' ', current_indent);
+ try self.underlying_writer.writeByteNTimes(
+ '\t',
+ divExact(usize, current_indent, indent_delta) catch return WriteError.OutOfMemory,
+ );
}
self.applied_indent = current_indent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment