diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 09:00:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | e0a2fd56777cf0f571125650ec74e75c3f6a8c44 (patch) | |
| tree | ee4c5e993e73b922c49e5b8e792d088f7219a7fa /src/builtins.zig | |
| parent | f41599385cc0ee990954b32eca79984d54d0c5e3 (diff) | |
| download | pardes-e0a2fd56777cf0f571125650ec74e75c3f6a8c44.tar.gz pardes-e0a2fd56777cf0f571125650ec74e75c3f6a8c44.zip | |
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 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index 756eeae7..b97f68f8 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1322,6 +1322,11 @@ pub const Mini = struct { // ---- search ---- +/// A Find or Grep that finds nothing fails as one, in words 9ns reads as +/// ENOENT (`not found`), the same for both. +const e_search_miss_find = "find: no match, not found"; +const e_search_miss_grep = "grep: no match, not found"; + /// List the files below this pane's directory whose names hold its argument, in a +Search. pub const Find = struct { pub const takes_arg = true; @@ -1330,7 +1335,8 @@ pub const Find = struct { pub fn run(c: Ctx) void { const pat = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); if (pat.len > 0) { - _ = look.runSearch(c.p, c.id, pat, .find, .top, true) catch |err| c.p.reportError(c.id, "find", err); + const rows = look.runSearch(c.p, c.id, pat, .find, .top, false) catch |err| return c.p.reportError(c.id, "find", err); + if (rows == 0) c.p.reportFailure(c.id, e_search_miss_find); return; } c.p.startPrompt(c.pane, &c.pane.body, .{ .search = config.find_marker }); @@ -1347,7 +1353,7 @@ pub const Grep = struct { const pat = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); if (pat.len > 0) { const rows = look.runSearch(c.p, c.id, pat, .grep, .top, false) catch |err| return c.p.reportError(c.id, "grep", err); - if (rows == 0) c.p.reportFailure(c.id, "grep: no match"); + if (rows == 0) c.p.reportFailure(c.id, e_search_miss_grep); return; } c.p.startPrompt(c.pane, &c.pane.body, .{ .search = config.grep_marker }); |
