diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 23:24:00 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:18 -0300 |
| commit | 5761f97293960ee7035f7866f09a9826a9e2f74a (patch) | |
| tree | 4666a3bcf5bd79d53dc590348922c8f1068be1f0 /src | |
| parent | e3cf9c1ffb54a64ee519f02afec17e6859ef8242 (diff) | |
| download | pardes-5761f97293960ee7035f7866f09a9826a9e2f74a.tar.gz pardes-5761f97293960ee7035f7866f09a9826a9e2f74a.zip | |
A refusal's +Unsaved goes in the session's directory when the active pane's directory is not there
Exit or Restore refused over a pane named into a directory that does
not exist made +Unsaved in that missing directory, where its rows
could not be looked at and a Save of it could only fail. The list now
goes in the session's directory when the asking pane's is not on disk.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/Output.zig | 5 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/Output.zig b/src/Output.zig index 4aa0c021..1160c455 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -656,7 +656,10 @@ pub fn openUnsaved(p: *Pardes, id: usize, content: []u8) void { return; } const pane = p.panes[id] orelse return p.gpa.free(content); - const dir = if (pane.file) |f| (std.fs.path.dirname(f.path) orelse "/") else pane.cwdSlice(); + const own = if (pane.file) |f| (std.fs.path.dirname(f.path) orelse "/") else pane.cwdSlice(); + // Its directory gone (or never there, a name not yet saved): the list + // goes in the session's, where a look from it can still resolve. + const dir = if (comptime pardes.hosted) (if (pardes.filesystem.localPath(own)) |local| (if (exec.isDirectory(local)) own else p.sessionDir()) else own) else own; const free = p.freeSlot() orelse return p.gpa.free(content); _ = open(p, free, dir, .unsaved, "", content) catch return; exec.placeNew(p, id, id, free, .doc); diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index f8391672..e0c4b21b 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1777,6 +1777,22 @@ test "exec Save writes the named file through the host" { try testing.expectEqualStrings(pane.file.?.content, p.fallback.get("/tmp/renamed.txt").?); } +test "a refusal's +Unsaved goes in the session's directory when the active pane's directory is not there" { + if (comptime !pardes.hosted) return; + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const serial = serialOf(p); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .name), "/tmp/pardes-no-such-dir-zz/x.txt\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .body), "edited\n").reply.status); + try testing.expectEqual(Status.err, wr(p, @intFromEnum(tree.TopFile.ctl), "Exit\n").reply.status); + const unsaved = for (p.panes) |slot| { + const pane = slot orelse continue; + const f = pane.file orelse continue; + if (f.output) |o| if (o.from == .unsaved) break f.path; + } else return error.NoUnsavedPane; + try testing.expectEqualStrings(p.sessionDir(), std.fs.path.dirname(unsaved).?); +} + test "a look at a file it may not read fails the write naming the file" { if (comptime !pardes.hosted) return; const p = try withFile(testing.allocator, "x\n"); |
