summaryrefslogtreecommitdiff
path: root/src/pdf_view.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 20:03:16 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit741d088c60da40fd811dedc80d8e62753959bfea (patch)
treeb414fb6f9bf4c246435c356f306a6792db37707b /src/pdf_view.zig
parentb6200709aa5e42f7a3d3702489301c71da8cd65d (diff)
downloadpardes-741d088c60da40fd811dedc80d8e62753959bfea.tar.gz
pardes-741d088c60da40fd811dedc80d8e62753959bfea.zip
A look at a PDF's page past its last is a miss, "has no page N", never the last page in its place
manual.pdf:999 on a twelve-page PDF showed page 12 and said nothing, so a stale or mistyped page number looked like a place found. It is now the miss a line past a file's end is, whether the PDF is open (it stays on its page) or not (nothing opens). A restore or a start-up page past the end still lands on the last. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pdf_view.zig')
-rw-r--r--src/pdf_view.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pdf_view.zig b/src/pdf_view.zig
index 5646a92f..e435d777 100644
--- a/src/pdf_view.zig
+++ b/src/pdf_view.zig
@@ -1877,6 +1877,9 @@ pub fn openPane(
id: usize,
path: []const u8,
page_one_based: usize,
+ /// A page past the last: the last page (a restore, a start-up), or
+ /// refused with error.NoSuchPage (a look, which names a place).
+ past_end: enum { last, refuse },
) !*pardes.Pane {
if (comptime !enabled) return error.PdfDisabled;
// The slot stays ours across the read: another request may make a
@@ -1891,6 +1894,7 @@ pub fn openPane(
break :virtual try State.openBytes(core.pdf_gpa, path, bytes, page_one_based);
};
errdefer state.deinit(core.pdf_gpa);
+ if (past_end == .refuse and page_one_based > state.page_count) return error.NoSuchPage;
const pane = try core.newDocPane(id);
pane.pdf = state;
pane.body.cur_pinned = true;