summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/views.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/views.zig b/src/views.zig
index c847b987..e99e1694 100644
--- a/src/views.zig
+++ b/src/views.zig
@@ -165,7 +165,10 @@ fn fresh(pane: *const Pane) PaneView {
pub fn installed(p: *Pardes, pane: *Pane) void {
pane.sized_by = p.view;
if (!several(p)) return;
- for (0..max) |k| if (k != p.view and isOpen(p, @intCast(k))) {
+ // The live view's slot too, owning nothing: a pane closed before its
+ // view next parks is torn down with that slot never written, and
+ // `tornDown` frees what the slots of the views not live hold.
+ for (0..max) |k| if (isOpen(p, @intCast(k))) {
pane.pv[k] = fresh(pane);
};
pane.pv_known = p.views_open;
@@ -197,7 +200,14 @@ fn unpark(p: *Pardes, k: u8) void {
const slot = p.parked[k].?;
copy(&fields, p, &slot.view);
p.view = k;
- for (p.panes) |s| if (s) |pane| apply(pane, &pane.pv[k]);
+ for (p.panes) |s| if (s) |pane| {
+ apply(pane, &pane.pv[k]);
+ // The live body owns the selections now; the slot, stale while its
+ // view is live, holds none (a pane closed before the view parks
+ // again would otherwise free them twice).
+ pane.pv[k].body.sels = &.{};
+ pane.pv[k].body.nsel = 0;
+ };
// The panes closed while it was out (a slot empty or another pane's
// now) leave its layout, and its keyboard leaves them.
for (0..p.ncol) |c| {