diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-24 14:16:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-24 14:26:04 -0300 |
| commit | f3b5bd10ceb4c4db7263739770d5e4bdb879ba75 (patch) | |
| tree | 39cbb04a514650f3453bfb0df3acb291d913f53d /src/builtins.zig | |
| parent | 9299281492d63e549ab274034efb59ab4e9d96f6 (diff) | |
| download | pardes-f3b5bd10ceb4c4db7263739770d5e4bdb879ba75.tar.gz pardes-f3b5bd10ceb4c4db7263739770d5e4bdb879ba75.zip | |
Search converge 7/6: a script's Grep or Find that misses opens nothing, a dumped query pane restores as plain text; fs.py's Recent and canary to the query pane
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index cda962de..d2f215d7 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1720,8 +1720,9 @@ pub const Find = struct { // (SPC f f) typed into; with a word (B2, a script) listed, the // keyboard left where it was, a script told of a miss. const pat = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); + const had = panes.Query.ofOwner(c.p, c.pane.serial) != null; panes.Query.open(c.p, c.id, .find, pat, pat.len == 0); - if (pat.len > 0) missed(c, e_search_miss_find); + if (pat.len > 0) missed(c, e_search_miss_find, had); } }; @@ -1733,19 +1734,22 @@ pub const Grep = struct { pub const output: OutputTraits = .{ .name = config.search_buffer, .steps = true, .locations = true }; pub fn run(c: Ctx) void { const pat = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); + const had = panes.Query.ofOwner(c.p, c.pane.serial) != null; panes.Query.open(c.p, c.id, .grep, pat, pat.len == 0); - if (pat.len > 0) missed(c, e_search_miss_grep); + if (pat.len > 0) missed(c, e_search_miss_grep, had); } }; /// A script's Find or Grep (a 9P write runs it to its end before it -/// answers) that found nothing fails as one: the query pane stays, its -/// count 0, and the write hears `not found`. -fn missed(c: Ctx, text: []const u8) void { +/// answers) that found nothing fails as one, opening nothing: a query pane +/// it made goes as an Esc takes it, one it reused stays, its count 0; the +/// write hears `not found`. +fn missed(c: Ctx, text: []const u8, reused: bool) void { if (!c.p.fs.serving) return; const qid = panes.Query.ofOwner(c.p, c.pane.serial) orelse return; - const q = c.p.panes[qid].?.query.?; - if (q.total == 0) c.p.reportFailure(c.id, text); + if (c.p.panes[qid].?.query.?.total != 0) return; + if (!reused) panes.Query.cancel(c.p, qid); + c.p.reportFailure(c.id, text); } /// Search in a query pane under this pane, line 1 the argument (`Panes`, |
