From f8fe738416fe3a40a7136f2cb5528e8fd57f40df Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 20:09:32 -0300 Subject: Recent and /recent keep PDFs and images as they keep files, and an open file's row is where its dot is now Only text files were recorded, so a PDF read yesterday was not there to find again, and an open file's row showed the place it last closed at, stale by however far it had moved since. A PDF is kept at its page and reopened there from its row; an image by its path; an open one's row reads its pane's place at the time of the listing. Co-Authored-By: Claude Opus 5.5 --- test/pdf.zig | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/pdf.zig') diff --git a/test/pdf.zig b/test/pdf.zig index 2a18ca3c..fbd580b3 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -384,6 +384,29 @@ test "PdfSections on a PDF with no outline says so and opens nothing" { } } +test "Recent keeps a PDF as it keeps a file: open, then closed at its page" { + if (!pdf_enabled or platform == .web) return; + const gpa = std.testing.allocator; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const fixture = try pdf_impl.makeNoOutlineTestPdf(gpa); + defer gpa.free(fixture); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "plain.pdf", .data = fixture }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; + var path_buf: [4200]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buf, "{s}/plain.pdf", .{dir}); + const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 28 }); + defer p.deinit(); + pardes.look.lookAt(p, p.active, path); + p.update(.{ .resize = .{ .cols = 80, .rows = 28 } }); // an update's end announces it + var out: std.Io.Writer.Allocating = .init(gpa); + defer out.deinit(); + try panes.Output.recentText(p, &out.writer, true); + var want: [4300]u8 = undefined; + try std.testing.expect(std.mem.indexOf(u8, out.written(), try std.fmt.bufPrint(&want, "{s}:1:1 open\n", .{path})) != null); +} + test "a look at a PDF's page past its last is a miss, never the last page" { if (!pdf_enabled or platform == .web) return; const gpa = std.testing.allocator; -- cgit v1.3