summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 07:24:46 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commitb3557640d6a0a4c2c41b6e1cae3c8182a32937ca (patch)
tree1d242911a8ff7c9ba4fb8b42c30b183a0e5878b4
parenta63185292e80beac3848f4f6395c61d941f5144f (diff)
downloadpardes-b3557640d6a0a4c2c41b6e1cae3c8182a32937ca.tar.gz
pardes-b3557640d6a0a4c2c41b6e1cae3c8182a32937ca.zip
New from a column's exec makes its scratch in the session's directory, as tagexec's does
A word run from a header runs in the session's directory (execDir), but New named its scratch after the pane with the keyboard. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--docs/fs.md4
-rw-r--r--src/ninep/cols.zig12
-rw-r--r--src/pardes.zig10
3 files changed, 21 insertions, 5 deletions
diff --git a/docs/fs.md b/docs/fs.md
index 5a4ece78..2f97661e 100644
--- a/docs/fs.md
+++ b/docs/fs.md
@@ -73,7 +73,9 @@ variable to know the mount is there, and takes the name from `$PARDES_9P`
(`pardes-9p-<pid or NAME>.sock`). A new pane made through `pane/new` is a scratch named
`<dir>/+New` until it is given a name, where `<dir>` is the session's
directory (the one pardes started in), whichever pane last had the keyboard:
-no pane asked for it, as acme's new window has acme's directory. A column may hold no pane, as in acme:
+no pane asked for it, as acme's new window has acme's directory. So is a
+`New` written to a column's `exec` or to `/tagexec`, a word in a tag no
+pane owns. A column may hold no pane, as in acme:
`Newcol` makes one empty, and closing a column's last pane leaves it empty
with its tag holding the keyboard (`focus` reads empty) and logs only the
`del`. `pane/new` places its pane as acme's makenewwindow(nil) does: in the
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig
index 7745ee5e..b00ecdba 100644
--- a/src/ninep/cols.zig
+++ b/src/ninep/cols.zig
@@ -177,6 +177,18 @@ pub fn writeExec(p: *Pardes, req: Req, serial: ?u32) Reply {
return .{ .tag = req.tag, .written = @intCast(req.data.len) };
}
+test "New written to a column's exec makes its scratch in the session's directory, as tagexec's does" {
+ const p = try th.withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const session = "/project/src";
+ @memcpy(p.session_dir[0..session.len], session);
+ p.session_dir_len = session.len;
+ const serial = layout.columnSerial(p, 0);
+ const exec_node = tree.Node.ofCol(serial, .exec);
+ try testing.expectEqual(tree.Status.ok, th.wr(p, exec_node, "New\n").reply.status);
+ try testing.expectEqualStrings("/project/src/+New", p.panes[p.active].?.file.?.path);
+}
+
/// 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 {
diff --git a/src/pardes.zig b/src/pardes.zig
index 739d5bf2..52d11bec 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4852,11 +4852,13 @@ pub const Pardes = struct {
errdefer p.gpa.free(content);
// A terminal that has not said where it is yet (the boot layout's)
// has no directory: the scratch is the session's, <cwd>/+New. So is
- // 9P's pane/new: no pane asked for it, whichever last had the
- // keyboard (acme's new window has acme's directory).
- const dir = if (kind == .fs) "" else paneDir(src);
+ // 9P's pane/new, and a New from a column's or the workspace's tag:
+ // no pane asked for it, whichever last had the keyboard (acme's new
+ // window has acme's directory).
+ const own = kind != .fs and !p.exec_header;
+ const dir = if (own) paneDir(src) else "";
const np = try panes.Output.open(p, free, if (dir.len == 0) p.sessionDir() else dir, .{ .cmd = .New }, "", content);
- if (kind != .fs) np.cwd = .{ .inherited = src };
+ if (own) np.cwd = .{ .inherited = src };
np.body.cur_pinned = true;
return np;
}