fix: NoSpaceLeft => OutOfMemory

NoSpaceLeft is not permitted to be returned in this context,
so turn it into OutOfMemory when we fail to write to the buffer.
This commit is contained in:
Abhinav Gupta
2024-12-11 09:21:31 -08:00
parent e2e12efbbf
commit 495e4081e4
2 changed files with 3 additions and 3 deletions

View File

@ -4214,7 +4214,7 @@ pub const Keybinds = struct {
}
var buffer_stream = std.io.fixedBufferStream(&buf);
try std.fmt.format(buffer_stream.writer(), "{}", .{k});
std.fmt.format(buffer_stream.writer(), "{}", .{k}) catch return error.OutOfMemory;
try v.formatEntries(&buffer_stream, formatter);
}
}

View File

@ -1171,7 +1171,7 @@ pub const Set = struct {
var iter = set.bindings.iterator();
while (iter.next()) |binding| {
buffer_stream.seekTo(pos) catch unreachable; // can't fail
try std.fmt.format(buffer_stream.writer(), ">{s}", .{binding.key_ptr.*});
std.fmt.format(buffer_stream.writer(), ">{s}", .{binding.key_ptr.*}) catch return error.OutOfMemory;
try binding.value_ptr.*.formatEntries(buffer_stream, formatter);
}
},
@ -1179,7 +1179,7 @@ pub const Set = struct {
.leaf => |leaf| {
// When we get to the leaf, the buffer_stream contains
// the full sequence of keys needed to reach this action.
try std.fmt.format(buffer_stream.writer(), "={s}", .{leaf.action});
std.fmt.format(buffer_stream.writer(), "={s}", .{leaf.action}) catch return error.OutOfMemory;
try formatter.formatEntry([]const u8, buffer_stream.getWritten());
},
}