diff options
| -rw-r--r-- | docs/fs.md | 3 | ||||
| -rw-r--r-- | src/Output.zig | 9 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 15 |
3 files changed, 22 insertions, 5 deletions
@@ -767,7 +767,8 @@ plain `zz.txt` is looked for as text, a miss logged as any look's -- and for a Find or Grep that finds nothing, `grep: no match, not found`; Grep walks every pane's directory on this host, passing over panes of the served tree (`/virtual/`, a peer's `/n/<name>/`) and directories not there, -so none of them spoils the rest; Find and Grep share one `+Search` a +so none of them spoils the rest; Find, Grep and a language server's lists +(Symbols, Diagnostics, Callers and the rest) share one `+Search` a directory, each run replacing what the last showed, as acme reuses a directory's `+Errors` (the exec reads that pane back; one that finds nothing empties it rather than leave the last rows), while a plain diff --git a/src/Output.zig b/src/Output.zig index 1461757f..f2ab1bda 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -428,11 +428,12 @@ pub fn hasFileSearch(p: *Pardes, dir: []const u8) bool { return false; } +/// Whether `from` fills its directory's one +Search, whatever filled it +/// last (Find, Grep, Symbols, Diagnostics, any language server's list), +/// each run replacing the last. A plain word's search (in a file or a PDF) +/// keeps a +Search a pattern: n/N walk from one such list to the next. fn fileSearch(from: Origin) bool { - return switch (from) { - .cmd => |c| c == .Find or c == .Grep, - else => false, - }; + return from != .search and std.mem.eql(u8, traits(from).name, config.search_buffer); } pub fn fillResults(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []const u8, content: []u8, initial_anchor: ?usize) !void { diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index b79b1ab8..0d3f084d 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2161,6 +2161,21 @@ test "a PDF's body reads its page's text layer, and takes no write" { try testing.expectEqual(E.INVAL, wr(p, body, "more\n").errno()); } +test "Grep, Symbols and Diagnostics share their directory's one +Search" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const id = p.active; + const Output = pardes.panes.Output; + try Output.fillResults(p, id, "/tmp", .{ .cmd = .Grep }, "x", try p.gpa.dupe(u8, "a.txt:1:1 x\n"), null); + try Output.fillResults(p, id, "/tmp", .{ .query = .document_symbols }, "", try p.gpa.dupe(u8, "a.txt:2:1 fn f\n"), null); + try Output.fillResults(p, id, "/tmp", .{ .query = .diagnostics }, "", try p.gpa.dupe(u8, "a.txt:3:1 error\n"), null); + var searches: usize = 0; + for (p.panes) |slot| if (slot) |q| if (q.file) |f| if (f.output != null) { + searches += @intFromBool(std.mem.eql(u8, f.path, "/tmp/+Search")); + }; + try testing.expectEqual(@as(usize, 1), searches); +} + test "every EINVAL a write gets says why, in its err record too; DEL is a control character in a line" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); |
