diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 80ff3495..c58452ee 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -7146,13 +7146,22 @@ pub const Pardes = struct { /// closing ends the session. Every route that closes a pane comes /// through here or removeColumn, so none picks focus for itself, and /// none by recency. - pub fn removePane(p: *Pardes, id: usize, to: ?usize) !void { + pub fn removePane(p: *Pardes, id: usize, to: ?usize) error{OutOfMemory}!void { const pane = p.panes[id] orelse return; + // What is attached to it closes with it, first, each giving its rows + // back to it: then its rows, theirs among them, go where a pane's go. + for (0..p.panes.len) |k| if (p.panes[k]) |other| if (k != id and other.attached_to == pane.serial) { + if (layout.ownerOf(p, k) != id) continue; + try p.removePane(k, id); + layout.compute(p); + }; + // An attachment's rows go back to its owner and nobody else. + const owner = layout.ownerOf(p, id); const place = layout.findPane(p, id); const emptied = if (place) |f| (if (p.col_n[f.col] == 1) f.col else null) else null; // Before anything is torn down, so a failure here changes nothing. try p.deinitPane(pane); - const gainer = layout.absorbVWeight(p, id, to); + const gainer = layout.absorbVWeight(p, id, owner orelse to); const beside = if (emptied) |c| p.besideColumn(c, p.rects[id]) else null; layout.removePane(p, id); p.panes[id] = null; |
