diff options
Diffstat (limited to 'src/Output.zig')
| -rw-r--r-- | src/Output.zig | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/Output.zig b/src/Output.zig index 3541fa57..01797cbe 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -164,6 +164,24 @@ test "stacked empty previews distinguish separators from trailing newlines" { try std.testing.expect(!locations.sameInput("x.c:1:1 \n", "x.c:1:1\n", &rows, .stacked)); } +test "two words looked for in a terminal share the directory's one +Search" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const term = for (p.panes, 0..) |slot, id| { + if (slot) |pane| if (pane.isTerminal()) break id; + } else return error.SkipZigTest; + p.word_look = true; + defer p.word_look = false; + try fillResults(p, term, "/work", .search, "foo", try p.gpa.dupe(u8, "a.txt:1:1 foo\n"), null); + try fillResults(p, term, "/work", .search, "bar", try p.gpa.dupe(u8, "a.txt:2:1 bar\n"), null); + var searches: usize = 0; + for (p.panes) |slot| { + const f = (slot orelse continue).file orelse continue; + searches += @intFromBool(std.mem.eql(u8, f.path, "/work/+Search")); + } + try std.testing.expectEqual(@as(usize, 1), searches); +} + test "Lspinfo and Lspwhy fill one +Lsp in a directory" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); @@ -506,7 +524,12 @@ pub fn fillResults(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: [] 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)) or (lspProse(from) and lspProse(o.from)); + // 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; + 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; if (!shared and by_arg and !std.mem.eql(u8, o.arg(), arg)) continue; |
