diff options
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 23 |
1 files changed, 23 insertions, 0 deletions
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); +} |
