From 2bdde8c5ec1049ea0f575c6f9165ed4cef00ea50 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 13:21:29 -0300 Subject: Align location results and configure source context --- test/pdf.zig | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'test/pdf.zig') diff --git a/test/pdf.zig b/test/pdf.zig index 4c0daf34..a835c6ea 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1408,12 +1408,22 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" { defer page_hits.deinit(gpa); try std.testing.expect(page_hits.hit_count >= 3); + p.locations_config.context = 2; + p.locations_config.tscontext = true; try p.runSearch(0, "Pardes", .text, .top); const results_id = pane.search_pane orelse return error.MissingPdfSearchResults; - const rows = p.panes[results_id].?.file.?.content; - try std.testing.expect(std.mem.indexOf(u8, rows, "design.pdf:1:1 Pardes\n") != null); - try std.testing.expect(std.mem.indexOf(u8, rows, "design.pdf:1:2 Pardes\n") != null); - try std.testing.expect(std.mem.indexOf(u8, rows, "design.pdf:1:3 Pardes\n") != null); + const results = p.panes[results_id].?.file.?; + var found: [3]bool = @splat(false); + for (results.location_rows, 0..) |row, index| { + // PDF locations address page/hit pairs, not binary file lines. + try std.testing.expectEqual(.match, row.kind); + if (!std.mem.endsWith(u8, row.path, "design.pdf") or row.at.line != 1) continue; + if (row.at.col < 1 or row.at.col > found.len) continue; + const line = pardes.modal.lineSlice(results.content, index); + try std.testing.expectEqualStrings("Pardes", line[row.code_start..]); + found[row.at.col - 1] = true; + } + for (found) |present| try std.testing.expect(present); // Exaggerate the cell aspect only to make the three fixture hits occupy // distinct fit-width crops. The search/reveal math must use the same -- cgit v1.3