From df6106af80e13cc4f0121b7f2caf5315a4453a9d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 10:03:10 -0300 Subject: Find and Grep share one +Search a directory, each run replacing the last Each Grep with a new pattern opened another +Search, until the column refused panes. Find and Grep now reuse their directory's one, as acme reuses +Errors, and the exec reads back the pane it filled; a plain word's LookWord list search keeps a pane a pattern as before. Co-Authored-By: Claude Opus 5.5 --- src/Output.zig | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/Output.zig') diff --git a/src/Output.zig b/src/Output.zig index b32a40a2..37d25168 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -406,6 +406,16 @@ pub fn open(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []const u return pane; } +/// Find and Grep share one +Search a directory, each run replacing what +/// the last showed, as acme reuses a directory's +Errors; a pane's own +/// search (LookWord list) keeps a pane a pattern. +fn fileSearch(from: Origin) bool { + return switch (from) { + .cmd => |c| c == .Find or c == .Grep, + else => false, + }; +} + pub fn fillResults(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []const u8, content: []u8, initial_anchor: ?usize) !void { var result_content = content; errdefer p.gpa.free(result_content); @@ -448,9 +458,12 @@ pub fn fillResults(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: [] const rp = slot orelse continue; const rf = if (rp.file) |*f| f else continue; const o = if (rf.output) |*x| x else continue; - if (!std.meta.eql(o.from, from)) continue; - if (by_arg and !std.mem.eql(u8, o.arg(), arg)) continue; + const shared = fileSearch(from) and fileSearch(o.from); + if (!shared and !std.meta.eql(o.from, from)) continue; + if (!shared and by_arg and !std.mem.eql(u8, o.arg(), arg)) continue; if (!std.mem.eql(u8, std.fs.path.dirname(rf.path) orelse "", dir)) continue; + o.from = from; + p.fs.refilled = rp.serial; try setArg(o, arg); if (std.mem.eql(u8, rf.content, result_content)) { p.gpa.free(result_content); -- cgit v1.3