summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.zig40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 60cc6112..3eae658a 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -3193,6 +3193,8 @@ fn pollFrame(ctx: ?*anyopaque) void {
s.reconcilePtys();
const core = s.core;
if (s.fs) |f| if (f.tick().pending) s.queue.push(.fs_ready);
+ // The authority owns its terminals even with its window closed.
+ pollCwds(core, s.ptys);
const g = s.gui orelse {
if (core.settings.window_opacity_pending) {
var unchanged_opacity: u8 = 100;
@@ -3233,7 +3235,6 @@ fn pollFrame(ctx: ?*anyopaque) void {
refitFont(g, core);
acknowledgeGuiFont(g, core);
}
- pollCwds(core, s.ptys);
const geom = windowCells(g);
if (updateCoreResize(core, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) resetScroll(g);
stepScroll(g, core, s.gpa);
@@ -8978,3 +8979,40 @@ test "trackpad rotation never types search keys into an insert-mode file or raw
try std.testing.expectEqualStrings("Back", client.pending.items[0].command);
try std.testing.expectEqualStrings("Forward", client.pending.items[1].command);
}
+
+test "a detached GUI authority follows terminal directory changes with no window" {
+ const gpa = std.testing.allocator;
+ const io = std.testing.io;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.createDirPath(io, "child");
+ var start_buf: [4096]u8 = undefined;
+ const start = start_buf[0..try tmp.dir.realPath(io, &start_buf)];
+ var cwd_buf: [4096]u8 = undefined;
+ const expected = cwd_buf[0..try tmp.dir.realPathFile(io, "child", &cwd_buf)];
+ const core = try pardes.Pardes.init(gpa, .{ .tty_only = true });
+ defer core.deinit();
+ core.panes[0].?.shell_spoke = true;
+ _ = core.settings.shell.effective.set("/bin/sh");
+ var queue: Queue = .{ .io = io, .gpa = gpa, .lsp_allocator = gpa };
+ defer queue.deinit();
+ var ptys: [pardes.MAX_PANES]?Pty = @splat(null);
+ var gens: [pardes.MAX_PANES]u32 = @splat(1);
+ const rcs: host_io.Shell.PromptFiles = .{};
+ var pipes: PipeTasks = .{};
+ var watches: file_watch.Table = @splat(null);
+ var shell: Shell = .{ .core = core, .io = io, .gpa = gpa, .lsp_allocator = gpa, .prompt_rcs = &rcs, .ptys = &ptys, .gens = &gens, .queue = &queue, .pipe_tasks = &pipes, .inotify_fd = -1, .watches = &watches };
+ defer shell.shutdownPtys();
+ const child = try host_io.forkShell(null, 0, &rcs, "/bin/sh", start, 24, 80);
+ ptys[0] = .{ .fd = child.file.handle, .pid = child.pid, .serial = core.panes[0].?.serial };
+ try std.testing.expect(host_io.writeFd(child.file.handle, "cd child\n"));
+ const until = std.Io.Clock.awake.now(io).toMilliseconds() + 2_000;
+ var actual: [4096]u8 = undefined;
+ while (std.Io.Clock.awake.now(io).toMilliseconds() < until) {
+ if (host_io.shellCwd(child.pid, &actual)) |cwd| if (std.mem.eql(u8, cwd, expected)) break;
+ try io.sleep(.fromMilliseconds(1), .awake);
+ }
+ try std.testing.expectEqualStrings(expected, host_io.shellCwd(child.pid, &actual) orelse return error.MissingCwd);
+ pollFrame(&shell);
+ try std.testing.expectEqualStrings(expected, core.panes[0].?.cwd.owned);
+}