Compare commits

...

2 commits

View file

@ -933,10 +933,10 @@ const Node = union(enum) {
try node.right.store(writer, eol_mode); try node.right.store(writer, eol_mode);
}, },
.leaf => |*leaf| { .leaf => |*leaf| {
_ = try writer.write(leaf.buf); try writer.writeAll(leaf.buf);
if (leaf.eol) switch (eol_mode) { if (leaf.eol) switch (eol_mode) {
.lf => _ = try writer.write("\n"), .lf => try writer.writeByte('\n'),
.crlf => _ = try writer.write("\r\n"), .crlf => try writer.writeAll("\r\n"),
}; };
}, },
} }
@ -1374,17 +1374,7 @@ pub fn store_to_string(self: *const Self, allocator: Allocator, eol_mode: EolMod
} }
fn store_to_file_const(self: *const Self, writer: *std.Io.Writer) StoreToFileError!void { fn store_to_file_const(self: *const Self, writer: *std.Io.Writer) StoreToFileError!void {
switch (builtin.os.tag) {
.linux => {
try self.root.store(writer, self.file_eol_mode); try self.root.store(writer, self.file_eol_mode);
},
else => {
var content: std.Io.Writer.Allocating = .init(self.external_allocator);
defer content.deinit();
try self.root.store(&content.writer, self.file_eol_mode);
try writer.writeAll(content.written());
},
}
try writer.flush(); try writer.flush();
} }