From e0a2fd56777cf0f571125650ec74e75c3f6a8c44 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 09:00:11 -0300 Subject: Grep and Find count the rows they found, so a hit opens its +Search and a miss fails Round 18 made a search that found nothing fail, but grep and find never counted their rows (only a pane search did), so every Grep read as a miss. Both count the lines they wrote now; a Find or Grep that finds nothing fails alike, `find: no match, not found` / `grep: ...`, ENOENT, and opens no empty +Search. Co-Authored-By: Claude Opus 5.5 --- src/look.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/look.zig') diff --git a/src/look.zig b/src/look.zig index ba022bef..fa86aee4 100644 --- a/src/look.zig +++ b/src/look.zig @@ -620,8 +620,10 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, kind: Search, start error.FileNotFound, error.NotDir, error.AccessDenied => continue, else => return err, }; + nrows = std.mem.count(u8, out[0..out_len], "\n"); } else if (kind == .find) { out_len = try filesystem.find(arena, dir, pat, out); + nrows = std.mem.count(u8, out[0..out_len], "\n"); } else if (pane.hasPdf()) { if (comptime pdf_enabled) { const found = try panes.Pdf.searchRows( @@ -661,7 +663,7 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, kind: Search, start nrows += 1; } } - if (!open_empty and (kind == .text or kind == .grep) and nrows == 0) return 0; + if (!open_empty and nrows == 0) return 0; const content = try p.gpa.dupe(u8, out[0..out_len]); // the buffer records WHICH search filled it, pattern and all: Find and // Grep are builtins (words you can execute), the bare `/` is a key -- cgit v1.3