summaryrefslogtreecommitdiff
path: root/src/pdf_view.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 01:21:23 -0300
committerGabriel Schneider <[email protected]>2026-10-01 01:35:12 -0300
commitea28dbf4ce827ee5544562bd19453c68599d912f (patch)
treed3803102715fce8b010ff0ea44840a1a6954dc38 /src/pdf_view.zig
parent77bda7e14e0ea81db5da54c233fc30d218773f47 (diff)
downloadpardes-ea28dbf4ce827ee5544562bd19453c68599d912f.tar.gz
pardes-ea28dbf4ce827ee5544562bd19453c68599d912f.zip
A +PdfSections row's first number is the page: a section that is not there, or is on another page, is a miss said, not a silent success
A look at `file.pdf:P:S` in +PdfSections went to section S whatever P said, and one past the last section did nothing and answered ok. The row's page is now held to: a section not in the outline, or on another page than the row names, fails with which, as every other miss does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pdf_view.zig')
-rw-r--r--src/pdf_view.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/pdf_view.zig b/src/pdf_view.zig
index 09c06356..b307d1f3 100644
--- a/src/pdf_view.zig
+++ b/src/pdf_view.zig
@@ -2248,7 +2248,14 @@ pub fn lookSection(
std.fmt.bufPrint(&joined_path, "{s}{s}{s}", .{ output_dir, separator, path }) catch return true;
if (!std.mem.eql(u8, owner.state.path, target_path)) return true;
- const destination = owner.state.sectionDestination(core.pdf_gpa, at.col - 1) orelse return true;
+ // A row is `file:PAGE:SECTION`, its first number the page as in every
+ // other location: a section there is none, or one on another page, is
+ // a miss said, never a silent jump.
+ var said: [160]u8 = undefined;
+ const destination = owner.state.sectionDestination(core.pdf_gpa, at.col - 1) orelse
+ return failSection(core, output_id, std.fmt.bufPrint(&said, "PdfSections: {s} has no section {d}", .{ std.fs.path.basename(owner.state.path), at.col }) catch "PdfSections: no such section");
+ if (destination == .internal and destination.internal.page + 1 != at.line)
+ return failSection(core, output_id, std.fmt.bufPrint(&said, "PdfSections: section {d} of {s} is on page {d}, not {d}", .{ at.col, std.fs.path.basename(owner.state.path), destination.internal.page + 1, at.line }) catch "PdfSections: that section is on another page");
switch (destination) {
.internal => |internal| {
look.clearNavigationSelection(core, owner.pane);
@@ -2261,6 +2268,12 @@ pub fn lookSection(
return true;
}
+fn failSection(core: *pardes.Pardes, id: usize, text: []const u8) bool {
+ core.look_missed = true;
+ core.reportFailure(id, text);
+ return true;
+}
+
pub fn resetPageChrome(pane: *pardes.Pane) void {
pane.body.cur_row = 0;
pane.body.cur_col = 0;