summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Output.zig6
-rw-r--r--src/ninep/ctl.zig9
2 files changed, 13 insertions, 2 deletions
diff --git a/src/Output.zig b/src/Output.zig
index e6d6f46c..495dbc43 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -436,7 +436,9 @@ pub fn fillResults(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []
const by_arg = std.meta.activeTag(from) != .query;
if (p.locations_config.context == 0 and !p.locations_config.tscontext) {
for (p.panes, 0..) |slot, i| {
- if (i == id) continue;
+ // A directory's +Search is found by its directory, whatever
+ // pane ran the search: that +Search itself too.
+ if (i == id and !fileSearch(from)) continue;
const rp = slot orelse continue;
const rf = if (rp.file) |*f| f else continue;
const output = if (rf.output) |*o| o else continue;
@@ -463,11 +465,11 @@ pub fn fillResults(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []
anchor = formatted.anchor;
}
for (p.panes, 0..) |slot, i| {
- if (i == id) continue;
const rp = slot orelse continue;
const rf = if (rp.file) |*f| f else continue;
const o = if (rf.output) |*x| x else continue;
const shared = fileSearch(from) and fileSearch(o.from);
+ if (i == id and !shared) continue;
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;
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 9bb863cf..40a1a7cd 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1860,6 +1860,15 @@ test "Grep with no hit says grep: no match and opens nothing, a missing pane dir
try testing.expect(std.mem.indexOf(u8, found.file.?.content, "other.txt") != null);
try testing.expectEqual(grepped.serial, found.serial);
try testing.expect(std.mem.indexOf(u8, found.file.?.content, "bravo here") == null);
+ // A Grep run from the +Search itself fills that one, never a second.
+ try testing.expectEqual(Status.ok, wr(p, Node.of(found.serial, .exec), "Grep bravo\n").reply.status);
+ try testing.expectEqualStrings(try std.fmt.bufPrint(&line, "{d}\n", .{found.serial}), rd(p, root_exec, 0, 64).bytes);
+ var searches: usize = 0;
+ for (p.panes) |slot| if (slot) |q| if (q.file) |f| if (f.output != null) {
+ searches += @intFromBool(std.mem.endsWith(u8, f.path, "/+Search"));
+ };
+ try testing.expectEqual(@as(usize, 1), searches);
+ try testing.expect(std.mem.indexOf(u8, found.file.?.content, "bravo here") != null);
// A second pane in a directory that is not there.
const other = try th.newPane(p);
_ = wr(p, Node.of(other, .name), "/tmp/pardes-no-such-dir-zz/b.txt\n");