summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index f3348ea5..59556649 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -1125,6 +1125,32 @@ test "Tty spawns a raw shell in the caller's directory" {
try std.testing.expect(found);
}
+test "a terminal respawned into a closed pane's slot hangs the old shell up first" {
+ // Hosts keep a shell per slot: were the spawn first, the close would
+ // end the new shell and leave the old one running.
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
+ defer p.deinit();
+ try std.testing.expect(p.executeBuiltinLine(0, "Tty"));
+ const slot = p.active;
+ while (p.nextEffect()) |_| {}
+ try p.removePane(slot, null);
+ try std.testing.expect(p.executeBuiltinLine(0, "Tty"));
+ try std.testing.expectEqual(slot, p.active);
+ var closed = false;
+ var spawned = false;
+ while (p.nextEffect()) |effect| switch (effect) {
+ .close_pty => |c| if (c.pane == slot) {
+ try std.testing.expect(!spawned);
+ closed = true;
+ },
+ .spawn => |s| if (s.pane == slot) {
+ spawned = true;
+ },
+ else => {},
+ };
+ try std.testing.expect(closed and spawned);
+}
+
test "Tty9p marks only the new Linux terminal for a mounted shell" {
if (comptime !hosted or @import("builtin").os.tag != .linux) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });