diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 6341de91..8e9d3c7e 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4588,7 +4588,7 @@ pub const Pardes = struct { // text under the shell. The shell keeps the keyboard. A boot // layout, like .classic's, not a placement. if (p.boot == .tty) { - const np = try p.newScratch(0, 1); + const np = try p.newScratch(0, 1, .scratch); layout.insert(p, 0, 1, 1); layout.splitBelow(p, 0, np); } @@ -4846,15 +4846,17 @@ pub const Pardes = struct { return pane; } - fn newScratch(p: *Pardes, from_id: usize, free: usize) !*Pane { + fn newScratch(p: *Pardes, from_id: usize, free: usize, kind: exec.NewPane) !*Pane { const src = p.panes[from_id] orelse return error.MissingPane; const content = try p.gpa.dupe(u8, ""); 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. - const dir = paneDir(src); + // 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); const np = try panes.Output.open(p, free, if (dir.len == 0) p.sessionDir() else dir, .{ .cmd = .New }, "", content); - np.cwd = .{ .inherited = src }; + if (kind != .fs) np.cwd = .{ .inherited = src }; np.body.cur_pinned = true; return np; } @@ -4868,7 +4870,7 @@ pub const Pardes = struct { /// A scratch for New (`.scratch`) or 9P's pane/new (`.fs`). pub fn newScratchFor(p: *Pardes, from_id: usize, kind: exec.NewPane) void { const free = p.freeSlot() orelse return p.reportError(from_id, "New", error.NoPaneSlots); - _ = p.newScratch(from_id, free) catch return; + _ = p.newScratch(from_id, free, kind) catch return; exec.placeNew(p, from_id, from_id, free, kind); } |
