diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/look.zig | 1 | ||||
| -rw-r--r-- | src/pdf_view.zig | 8 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/look.zig b/src/look.zig index a230d740..a4a64b14 100644 --- a/src/look.zig +++ b/src/look.zig @@ -598,7 +598,6 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, start: SearchStart, const found = try panes.Pdf.searchRows( &pane.pdf.?, p.pdf_gpa, - arena, pat, start == .cursor, out, 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; } |
