diff options
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 }); |
