diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 06:47:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 07:16:43 -0300 |
| commit | 528c5a28ac3b813a2d0c06a019d7758476257915 (patch) | |
| tree | 777dd00892ea0d8ef690e8a646c2a8f93b7414fa | |
| parent | 24dbdf73f92cd0a4b5ba130abe182cbcf9b3e472 (diff) | |
| download | pardes-528c5a28ac3b813a2d0c06a019d7758476257915.tar.gz pardes-528c5a28ac3b813a2d0c06a019d7758476257915.zip | |
A second LookWord list look in a directory refills its +Search, as a terminal's word looks already did, rather than stacking another
Each word looked at with LookWord list opened a +Search of its own in
the same directory. Word looks now share the directory's one, the next
word refilling it; a `/` search still keeps a +Search each.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | src/Output.zig | 9 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 23 | ||||
| -rw-r--r-- | test/snapshots/rsearch.golden | 34 |
3 files changed, 46 insertions, 20 deletions
diff --git a/src/Output.zig b/src/Output.zig index e6448e36..fc300e8b 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -525,10 +525,11 @@ pub fn fillResults(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: [] const rf = if (rp.file) |*f| f else continue; const o = if (rf.output) |*x| x else continue; // A file search's rows share the directory's one +Search, and so do - // a terminal's word looks (a look of a word no file names, clicked - // or written): the next word refills it rather than stacking - // another. A `/` search keeps a +Search each, which n and N walk. - const terminal_word = p.word_look and from == .search and pane.isTerminal() and o.from == .search; + // word looks (`LookWord list`, a terminal's word: a look of a word + // no file names, clicked or written): the next word refills it + // rather than stacking another. A `/` search keeps a +Search each, + // which n and N walk. + const terminal_word = p.word_look and from == .search and o.from == .search; const shared = (fileSearch(from) and fileSearch(o.from)) or terminal_word or (lspProse(from) and lspProse(o.from)); if (i == id and !shared) continue; if (!shared and !std.meta.eql(o.from, from)) continue; diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 70ed51a7..ad427cad 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -4165,3 +4165,26 @@ test "`@pN:` looks at pane N as `a.txt:` looks at a.txt, and a line past the end try testing.expect(std.mem.endsWith(u8, said, "/test.txt:99999 has no line 99999")); } } + +test "a second LookWord list look in a directory refills its +Search rather than stacking another" { + if (comptime !pardes.hosted) return; + const gpa = testing.allocator; + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "words.txt", .data = "alpha beta\nalpha beta\n" }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var path_buf: [4200]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buf, "{s}/words.txt", .{dir}); + const p = try Pardes.init(gpa, .{ .file = path, .tty_only = true, .cols = 80, .rows = 30 }); + defer p.deinit(); + _ = wr(p, @intFromEnum(tree.TopFile.ctl), "LookWord list\n"); + pardes.look.lookAt(p, 0, "alpha"); + pardes.look.lookAt(p, 0, "beta"); + var searches: usize = 0; + for (p.panes) |slot| if (slot) |pn| if (pn.file) |f| if (std.mem.endsWith(u8, f.path, "+Search")) { + searches += 1; + try testing.expectEqualStrings("beta", f.output.?.arg()); + }; + try testing.expectEqual(@as(usize, 1), searches); +} diff --git a/test/snapshots/rsearch.golden b/test/snapshots/rsearch.golden index eb98853a..870831b4 100644 --- a/test/snapshots/rsearch.golden +++ b/test/snapshots/rsearch.golden @@ -18,24 +18,26 @@ |15: 4 count_x again |16: 5 == snap select grid=210x31 cursor=14,10 -|16: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Collapse Del LocationsConfig -|17: 1 code.txt:4:1-8 -|18: 2 pick two words -|19: 3 -== snap path-open grid=210x31 cursor=16,22 -|19: /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Tty Collapse Del -|20: 1 d1 -|21: 2 d2 -|22: 3 DEPTARGET -|23: 4 d4 -|24: 5 d5 -|25: 6 d6 +|12: 1 code.txt:4:1-8 +|13: 2 pick two words +|14: 3 +|15: +|16: +== snap path-open grid=210x31 cursor=16,17 +|14: /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Tty Collapse Del +|15: 1 d1 +|16: 2 d2 +|17: 3 DEPTARGET +|18: 4 d4 +|19: 5 d5 +|20: 6 d6 == snap step1 grid=210x31 cursor=13,9 +|12: 2 run count_x now +|13: 3 code.txt:3:1-7 == snap step2 grid=210x31 cursor=13,9 == snap step3 grid=210x31 cursor=13,9 == snap selclick grid=210x31 cursor=14,10 +|12: 1 code.txt:4:1-8 +|13: 2 pick two words == snap outside grid=210x31 cursor=20,10 -|25: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Collapse Del LocationsConfig -|26: 1 code.txt:4:10-14 -|27: 2 pick two words -|28: 3 +|12: 1 code.txt:4:10-14 |
