diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout.zig | 16 | ||||
| -rw-r--r-- | src/ninep/tree.zig | 10 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/layout.zig b/src/layout.zig index bdef9675..644054ed 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -447,8 +447,9 @@ pub fn everyPaneRoomy(p: *Pardes) bool { return true; } -/// Places `id` in column `c` by halving its tallest unfolded pane, when -/// that leaves both their rows; false, and `id` in no column, when not. +/// Places `id` last in column `c`, where acme's coladd puts a new window, +/// with half the rows of the column's tallest unfolded pane, when that +/// leaves both their rows; false, and `id` in no column, when not. pub fn splitTallest(p: *Pardes, c: usize, id: usize) bool { compute(p); var tall: ?usize = null; @@ -457,8 +458,15 @@ pub fn splitTallest(p: *Pardes, c: usize, id: usize) bool { if (tall == null or p.rects[k].h > p.rects[tall.?].h) tall = k; } const v = tall orelse return false; - if (p.rects[v].h < minRows(p, v) + minRows(p, id)) return false; - splitAt(p, c, id, p.rects[v].y + p.rects[v].h / 2); + const h = p.rects[v].h; + // Its tag wraps at the column's width: measured there, not at none. + p.rects[id].w = p.col_w[c]; + if (h < minRows(p, v) + minRows(p, id)) return false; + snapColWeights(p, c); + insert(p, c, p.col_n[c], id); + const given = std.math.clamp(h / 2, minRows(p, id), h - minRows(p, v)); + p.panes[v].?.vweight = @floatFromInt(h - given); + p.panes[id].?.vweight = @floatFromInt(given); return true; } diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 27091112..af1c589d 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1560,3 +1560,13 @@ test "an a, c or i text cut short through exec is an err in the log, not a msg" try testing.expect(!th.logHas(p, "msg 1 Edit: a, c or i")); try testing.expectEqualStrings("abc\n", p.panes[0].?.file.?.content); } + +test "a pane made from pane/new goes last in its column, even when the last pane has no room to halve" { + const p = try th.withFile(testing.allocator, "x\n"); + defer p.deinit(); + for (0..3) |_| { + const made = call(p, .{ .tag = 1, .op = .open, .node = @intFromEnum(TopFile.new) }).reply.handle; + p.sync(); + try testing.expectEqual(made, p.panes[p.col_panes[0][p.col_n[0] - 1]].?.serial); + } +} |
