From a0114d0b8be05d62bc1eb0e68642f7c31a766ade Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 08:18:25 -0300 Subject: Grep with no hit says grep: no match, and a pane directory that is not there is passed over Grep walks every pane's directory; one not there (a scratch named into a directory not made yet) failed the whole search with `file not found`. Such a root is passed over now, and a search that finds nothing says `grep: no match` and opens no empty +Search. Co-Authored-By: Claude Opus 5.5 --- src/look.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/look.zig') diff --git a/src/look.zig b/src/look.zig index 87dcede3..ba022bef 100644 --- a/src/look.zig +++ b/src/look.zig @@ -612,8 +612,14 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, kind: Search, start roots[nroots] = d; nroots += 1; } + // A pane's directory that is not there (a scratch named into one + // not made yet, a peer's) has nothing to grep: passed over, not the + // search's failure. for (roots[0..nroots]) |r| - out_len += try filesystem.grep(arena, p.gpa, r, dir, pat, out[out_len..]); + out_len += filesystem.grep(arena, p.gpa, r, dir, pat, out[out_len..]) catch |err| switch (err) { + error.FileNotFound, error.NotDir, error.AccessDenied => continue, + else => return err, + }; } else if (kind == .find) { out_len = try filesystem.find(arena, dir, pat, out); } else if (pane.hasPdf()) { @@ -655,7 +661,7 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, kind: Search, start nrows += 1; } } - if (!open_empty and kind == .text and nrows == 0) return 0; + if (!open_empty and (kind == .text or kind == .grep) 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