summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Trail.zig29
-rw-r--r--core/panes.zig3
2 files changed, 32 insertions, 0 deletions
diff --git a/core/Trail.zig b/core/Trail.zig
index 3faccafa..7166d810 100644
--- a/core/Trail.zig
+++ b/core/Trail.zig
@@ -631,3 +631,32 @@ test "Ctrl-o goes back one place in a reader's walk and Ctrl-i forward again; pa
try std.testing.expect(!walkBy(p, p.view().active, -1));
try std.testing.expect(!walkBy(p, f.held, -1));
}
+
+test "closing a held pane closes its reader; a kept reader stays; typed into, a reader is held and its walk leaves its tag" {
+ var f: Fixture = .{ .p = undefined, .tmp = undefined };
+ try f.init(60);
+ defer f.deinit();
+ const p = f.p;
+ const owner = p.panes[f.held].?.serial;
+ var buf: [4096 + 128]u8 = undefined;
+ f.look(f.held, "rank.zig", 12);
+ f.look(p.view().active, "place.zig", 8);
+ const r = p.view().active;
+ // Typed into: held, its walk gone from its tag, kept when its owner goes.
+ typeKeys(p, "ix");
+ p.update(.{ .key = .{ .cp = pardes.Key.escape } });
+ p.sync();
+ try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, p.panes[r].?), try std.fmt.bufPrint(&buf, "{s}/place.zig Save", .{f.dir})));
+ try std.testing.expectEqual(@as(u8, 0), p.panes[r].?.trail.n);
+ // The next jump from its old owner makes a new reader.
+ f.look(f.held, "rank.zig", 30);
+ const fresh = p.view().active;
+ try std.testing.expect(fresh != r);
+ try std.testing.expectEqual(owner, p.panes[fresh].?.trail.steps[0].owner);
+ // Del of the owner: its reader goes with it; the edited one stays.
+ const fresh_serial = p.panes[fresh].?.serial;
+ try p.removePane(f.held, null);
+ p.sync();
+ try std.testing.expect(p.paneBySerial(fresh_serial) == null);
+ try std.testing.expect(p.panes[r] != null);
+}
diff --git a/core/panes.zig b/core/panes.zig
index c11fdc94..1a27b238 100644
--- a/core/panes.zig
+++ b/core/panes.zig
@@ -1510,6 +1510,9 @@ pub fn removePane(p: *Pardes, id: usize, to: ?usize) error{OutOfMemory}!void {
try p.removePane(k, id);
layout.compute(p);
};
+ // A held pane's reader is its tether: it closes with it (pick-ui
+ // SPEC ยง11), its rows going where a closed pane's go.
+ if (Trail.readerOf(p, pane)) |r| try p.removePane(r, null);
// A docked pane's rows go back to its owner and nobody else.
const owner = layout.ownerOf(p, id);
const place = layout.findPane(p, id);