summaryrefslogtreecommitdiff
path: root/src/pdf_view.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdf_view.zig')
-rw-r--r--src/pdf_view.zig8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/pdf_view.zig b/src/pdf_view.zig
index d357b9cb..a0a48178 100644
--- a/src/pdf_view.zig
+++ b/src/pdf_view.zig
@@ -1169,7 +1169,6 @@ pub fn visibleText(
pub fn searchRows(
state: *State,
gpa: std.mem.Allocator,
- arena: std.mem.Allocator,
pattern: []const u8,
from_cursor: bool,
out: []u8,
@@ -1203,15 +1202,14 @@ pub fn searchRows(
for (0..found.hit_count) |hit_index| {
if (result.rows >= max_hits) break;
- const line = try std.fmt.allocPrint(arena, "{s}:{d}:{d} {s}\n", .{
+ // A row that does not fit ends the list.
+ const line = std.fmt.bufPrint(out[result.bytes..], "{s}:{d}:{d} {s}\n", .{
shown, page + 1, hit_index + 1, snippet,
- });
- if (line.len > out.len - result.bytes) return result;
+ }) catch return result;
if (from_cursor and
(page < state.page or
(page == state.page and cursor_hit != null and hit_index <= cursor_hit.?)))
result.anchor = result.rows;
- @memcpy(out[result.bytes..][0..line.len], line);
result.bytes += line.len;
result.rows += 1;
}