diff options
Diffstat (limited to 'src/pdf_view.zig')
| -rw-r--r-- | src/pdf_view.zig | 15 |
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; |
