summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 11:30:08 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit35f06a55bad1891e3d5e779630b232b2c322bc83 (patch)
tree9b6e3bc3b02667c8849cdad54ebf3d5cd7a7225c /src
parent0e6501ce210481c095e6f70a27e7f125f7af3761 (diff)
downloadpardes-35f06a55bad1891e3d5e779630b232b2c322bc83.tar.gz
pardes-35f06a55bad1891e3d5e779630b232b2c322bc83.zip
/recent shows a name as /index does, a newline in it escaped
It printed paths raw, so a name holding a newline read as two rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/Output.zig4
-rw-r--r--src/ninep/ctl.zig8
2 files changed, 11 insertions, 1 deletions
diff --git a/src/Output.zig b/src/Output.zig
index eb9e8db4..b3c31be2 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -570,7 +570,9 @@ pub fn recentText(p: *Pardes, w: *std.Io.Writer, look_rows: bool) !void {
};
const state: []const u8 = if (is_open) "open" else "(closed)";
if (!look_rows) {
- try w.print("{s} {s}\n", .{ if (is_open) "open" else "closed", e.path });
+ // A name as /index shows it: one line, a newline in it `\n`.
+ var name_buf: [4 * 4096]u8 = undefined;
+ try w.print("{s} {s}\n", .{ if (is_open) "open" else "closed", pardes.ctlfs.events.shown(e.path, &name_buf) });
} else if (e.line == 0) {
try w.print("{s} {s}\n", .{ e.path, state });
} else if (e.aline != 0 and (e.aline != e.line or e.acol != e.col)) {
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 92342525..4abb6fcd 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2300,6 +2300,14 @@ test "Back and Forward over a closed file's entries: one reopen is that file's p
try testing.expectEqual(c_serial, p.panes[p.active].?.serial);
}
+test "/recent shows a name as /index does, a newline in it escaped" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ p.recent.opened(p.recentGpa(), "/tmp/a\nb\\c");
+ const text = rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes;
+ try testing.expect(std.mem.indexOf(u8, text, "closed /tmp/a\\nb\\\\c\n") != null);
+}
+
test "a remembered place is clamped to the file as it is now, its selection's two ends kept where they fit" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();