From f207f1d4d56d1012766e6206e713f2b3da70579d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 10:11:14 -0300 Subject: A column takes panes until their minimums fill it, not until none can be halved Placement halved the tallest pane or refused, so 11 panes filled 48 rows that hold 16 at their tag and two rows each: the refusal did not match the documented arithmetic. When no pane can be halved but the minimums with the new pane's fit, the column's rows are shared out again; and a refused pane's removal leaves no pane under its minimum. Co-Authored-By: Claude Opus 5.5 --- src/ninep/ctl.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/ninep/ctl.zig') diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index fbda6113..6631e5f9 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2088,6 +2088,24 @@ test "a bad event record says what is wrong with it" { _ = call(p, .{ .tag = 3, .op = .release, .node = event, .handle = h }); } +test "a column takes panes until their documented minimums fill it, not until none can be halved" { + const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 50 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const new = @intFromEnum(tree.TopFile.new); + while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync(); + p.sync(); + const avail = p.screen_h - (p.topBarHeight() + p.columnBarHeight()); + for (0..p.ncol) |c| { + var need: u32 = 0; + for (p.col_panes[c][0..p.col_n[c]]) |k| need += layout.minRows(p, k); + // Refused only when one more pane's tag and two rows would not fit. + if (p.col_n[c] > 1) try testing.expect(avail - need < 3); + // Every pane keeps its minimum. + for (p.col_panes[c][0..p.col_n[c]]) |k| try testing.expect(p.rects[k].h >= layout.minRows(p, k)); + } +} + test "size is monotonic: growing is never refused, and a size once taken is taken again" { const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 }); defer p.deinit(); -- cgit v1.3