summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 20:09:32 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitf8fe738416fe3a40a7136f2cb5528e8fd57f40df (patch)
tree4f5f3ff990d79523a191c0754a154f3f5ffdee43 /test/pdf.zig
parent506ca99f13aec67d593e4a30bbe416dea176d0ba (diff)
downloadpardes-f8fe738416fe3a40a7136f2cb5528e8fd57f40df.tar.gz
pardes-f8fe738416fe3a40a7136f2cb5528e8fd57f40df.zip
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 <[email protected]>
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig23
1 files changed, 23 insertions, 0 deletions
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;