fix(container): check border sides configurations before trying to create borders
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 28s

This commit is contained in:
2025-03-01 20:58:34 +01:00
parent e2fe884925
commit bec0cf2987

View File

@@ -48,6 +48,7 @@ pub const Border = packed struct {
std.debug.assert(frame.len == 6);
// render top and bottom border
if (this.sides.top or this.sides.bottom) {
for (0..size.cols) |col| {
const last_row = @as(usize, size.rows - 1) * @as(usize, size.cols);
if (this.sides.left and col == 0) {
@@ -69,7 +70,9 @@ pub const Border = packed struct {
if (this.sides.top) cells[col].style.fg = this.color;
if (this.sides.bottom) cells[last_row + col].style.fg = this.color;
}
}
// render left and right border
if (this.sides.left or this.sides.right) {
for (1..size.rows -| 1) |row| {
const idx = (row * size.cols);
if (this.sides.left) {
@@ -82,6 +85,7 @@ pub const Border = packed struct {
}
}
}
}
test "all sides" {
const event = @import("event.zig");