summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Output.zig9
-rw-r--r--src/ninep/ctl.zig23
2 files changed, 28 insertions, 4 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);
+}