From 675191642edfd5a4492cfb966e65d973f4ffcf0d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 08:11:52 -0300 Subject: A column ctl write reads back what it touched alone writeCtl never cleared what the last write touched before its lines ran, so `New` through col//ctl read back the earlier write's serial too. Co-Authored-By: Claude Opus 5.5 --- src/ninep/cols.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig index b00ecdba..efb62cfe 100644 --- a/src/ninep/cols.zig +++ b/src/ninep/cols.zig @@ -126,6 +126,8 @@ pub fn released(p: *Pardes, serial: ?u32) void { /// Delcol, Joincol, New, Tty -- one a line, each run as from that tag. What /// they say is the session's in the log (`msg -`), not the focused pane's. pub fn writeCtl(p: *Pardes, req: Req, serial: u32) Reply { + // What this write touched, alone, reads back (runBuiltin notes it). + p.fs.results_len = 0; p.fs.session_write = true; defer p.fs.session_write = false; var lines = std.mem.splitScalar(u8, req.data, '\n'); @@ -189,6 +191,17 @@ test "New written to a column's exec makes its scratch in the session's director try testing.expectEqualStrings("/project/src/+New", p.panes[p.active].?.file.?.path); } +test "New written to a column's ctl reads back the new pane alone, as its exec does" { + const p = try th.withFile(testing.allocator, "x\n"); + defer p.deinit(); + const root_exec = @intFromEnum(tree.TopFile.exec); + _ = th.wr(p, root_exec, "Msg before\n"); + const ctl_node = tree.Node.ofCol(layout.columnSerial(p, 0), .ctl); + try testing.expectEqual(tree.Status.ok, th.wr(p, ctl_node, "New\n").reply.status); + var want: [16]u8 = undefined; + try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{p.panes[p.active].?.serial}), th.rd(p, root_exec, 0, 64).bytes); +} + /// rmdir of a column closes it when it is empty; one with panes is /// refused, saying so (close them, or Delcol on its ctl, which asks first). pub fn remove(p: *Pardes, req: Req, serial: u32, file: tree.ColFile) Reply { -- cgit v1.3