summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 08:18:25 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commita0114d0b8be05d62bc1eb0e68642f7c31a766ade (patch)
treed96c79f59b6d852608e889e68a647813da896bdc /src/look.zig
parent4a7d377d160cd95c89acad2abaf08bc533ff02a8 (diff)
downloadpardes-a0114d0b8be05d62bc1eb0e68642f7c31a766ade.tar.gz
pardes-a0114d0b8be05d62bc1eb0e68642f7c31a766ade.zip
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 <[email protected]>
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig10
1 files changed, 8 insertions, 2 deletions
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