summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 10:03:10 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commitdf6106af80e13cc4f0121b7f2caf5315a4453a9d (patch)
treebeb1176f4b6cf13bb65732ccbf0d9f6e1049f605 /src/ninep/ctl.zig
parentae71c2e2845be4a5595e7fae117c0ef22c16c0c0 (diff)
downloadpardes-df6106af80e13cc4f0121b7f2caf5315a4453a9d.tar.gz
pardes-df6106af80e13cc4f0121b7f2caf5315a4453a9d.zip
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 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index a474c781..fbda6113 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -73,6 +73,7 @@ pub fn run(p: *Pardes, id: usize, exec: bool, text: []const u8, in_tag: bool) vo
// An exec answers the pane it went to: a command pane it reused, or
// the terminal it typed into.
p.look_missed = false;
+ p.fs.refilled = null;
const went: ?usize = if (exec) pardes.exec.execute(p, id, text) else blk: {
look.lookAt(p, id, text);
break :blk null;
@@ -88,6 +89,9 @@ pub fn run(p: *Pardes, id: usize, exec: bool, text: []const u8, in_tag: bool) vo
created = true;
};
if (created) return;
+ // A +Search it filled again (Find and Grep reuse one): that is what it
+ // touched.
+ if (p.fs.refilled) |serial| if (p.paneBySerial(serial) != null) return noteResult(p, serial);
if (went) |dst| if (p.panes[dst]) |pane| return noteResult(p, pane.serial);
noteResult(p, if (exec) context else (p.panes[p.active] orelse return).serial);
}
@@ -1841,7 +1845,8 @@ test "Grep with no hit says grep: no match and opens nothing, a missing pane dir
const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
var line: [4200]u8 = undefined;
_ = wr(p, Node.of(serialOf(p), .name), try std.fmt.bufPrint(&line, "{s}/a.txt\n", .{dir}));
- // A hit opens its +Search, a row a line: exec reads it back.
+ // A hit opens its +Search, a row a line: exec reads it back. Find and
+ // Grep share it, a directory's one +Search, each run replacing it.
try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .exec), "Grep bravo\n").reply.status);
const grepped = p.panes[p.paneBySerial(try std.fmt.parseInt(u32, std.mem.trimEnd(u8, rd(p, root_exec, 0, 64).bytes, "\n"), 10)).?].?;
try testing.expectEqual(@as(usize, 2), std.mem.count(u8, grepped.file.?.content, "other.txt:"));
@@ -1850,6 +1855,8 @@ test "Grep with no hit says grep: no match and opens nothing, a missing pane dir
try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .exec), "Find other\n").reply.status);
const found = p.panes[p.paneBySerial(try std.fmt.parseInt(u32, std.mem.trimEnd(u8, rd(p, root_exec, 0, 64).bytes, "\n"), 10)).?].?;
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 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");