diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 12:40:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 14:56:36 -0300 |
| commit | d4e7694b4fedcf532f469095fb07df60f134e9d2 (patch) | |
| tree | 5c7c1c31dbd86f236b5a6966208d4b0553a9ae1d /src | |
| parent | a66a9eb6e0c69cfcb63717bc27704cdc96f382b4 (diff) | |
| download | pardes-d4e7694b4fedcf532f469095fb07df60f134e9d2.tar.gz pardes-d4e7694b4fedcf532f469095fb07df60f134e9d2.zip | |
idioms #12, Query and Stream: Stream.query returns OutOfMemory for Query to report, walkDir's anyerror is the three errors it has, Query's rows say their counts through buffers proven big enough, its open, produce, noteRows, fillList and land report an allocation that failed (reportError) instead of returning quietly, tagPrefix names its set, and std.fs.path is std.Io.Dir.path
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
| -rw-r--r-- | src/Query.zig | 74 | ||||
| -rw-r--r-- | src/Stream.zig | 28 |
2 files changed, 51 insertions, 51 deletions
diff --git a/src/Query.zig b/src/Query.zig index 0f08ce80..0220a983 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -239,7 +239,7 @@ pub fn open(p: *Pardes, from: usize, source: Source, arg: []const u8, focus: boo if (focus) toLineOne(p, from); return; } - const line = std.mem.concat(p.scratch.allocator(), u8, &.{ wordOf(source), if (source == .text) "" else " ", arg }) catch return; + const line = std.mem.concat(p.scratch.allocator(), u8, &.{ wordOf(source), if (source == .text) "" else " ", arg }) catch |err| return p.reportError(from, "search", err); var id: usize = undefined; const existing = ofOwner(p, owner.serial); if (existing) |reused| { @@ -250,7 +250,7 @@ pub fn open(p: *Pardes, from: usize, source: Source, arg: []const u8, focus: boo if (q.frozen and q.saved == null) q.saved = save(p, rp, q) catch null; q.frozen = false; const f = &rp.file.?; - const new = std.mem.concat(p.gpa, u8, &.{ line, "\n" }) catch return; + const new = std.mem.concat(p.gpa, u8, &.{ line, "\n" }) catch |err| return p.reportError(from, "search", err); File.setContent(p, f, new); q.reset(p); if (rp.collapsed) layout.toggleCollapse(p, id); @@ -409,7 +409,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { const asked = parse(line); if (changed) { const was = q.source; - const new_asked = p.gpa.dupe(u8, line) catch return; + const new_asked = p.gpa.dupe(u8, line) catch |err| return p.reportError(id, "search", err); p.gpa.free(q.asked); q.asked = new_asked; q.made_gen = std.math.maxInt(u64); @@ -490,7 +490,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { makeNameRows(p, id) catch |err| p.reportError(id, "search", err); }, .grep => { - const dir = std.fs.path.dirname(f.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(f.path) orelse "/"; if (changed) { q.found.clearRetainingCapacity(); q.found_bytes.clearRetainingCapacity(); @@ -500,7 +500,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { // On the disk engine's worker, once the typing pauses. // A script's (a 9P write): run to its end before it answers. if (a.pat.len > 0) { - Stream.query(p, rp.serial, .grep, a.pat, dir, if (p.fs.serving) .now else .typed); + Stream.query(p, rp.serial, .grep, a.pat, dir, if (p.fs.serving) .now else .typed) catch |err| return p.reportError(id, "search", err); if (p.fs.serving) Stream.step(p); } else if (p.stream.target == rp.serial) { _ = p.stream.stop(); @@ -548,13 +548,13 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz q.names.reset(); q.found.clearRetainingCapacity(); q.found_bytes.clearRetainingCapacity(); - const dir = std.fs.path.dirname(rp.file.?.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(rp.file.?.path) orelse "/"; const gpa = p.gpa; switch (source) { // The files under the directory, listed once on the disk engine's // worker (rg --files, else the walk); each keystroke scores them. .find => { - Stream.query(p, rp.serial, .files, "", dir, .now); + Stream.query(p, rp.serial, .files, "", dir, .now) catch |err| return p.reportError(id, "search", err); if (p.fs.serving) Stream.step(p); }, .recent => { @@ -653,7 +653,7 @@ fn noteRows(p: *Pardes, id: usize, note: []const u8) void { const rp = p.panes[id].?; const q = rp.query.?; q.items.clearRetainingCapacity(); - q.items.append(p.gpa, .{ .kind = .note }) catch return; + q.items.append(p.gpa, .{ .kind = .note }) catch |err| return p.reportError(id, "search", err); q.current = null; q.total = 0; q.k = 0; @@ -661,7 +661,7 @@ fn noteRows(p: *Pardes, id: usize, note: []const u8) void { var out: std.ArrayList(u8) = .empty; defer out.deinit(p.gpa); var rows: std.ArrayList(locations.Row) = .empty; - writeRow(p, &out, &rows, note[0 .. note.len - 1], .{ .kind = .context, .path = &.{}, .at = .{}, .location_end = 0, .code_start = 0 }) catch return; + writeRow(p, &out, &rows, note[0 .. note.len - 1], .{ .kind = .context, .path = &.{}, .at = .{}, .location_end = 0, .code_start = 0 }) catch |err| return p.reportError(id, "search", err); setRows(p, rp, &out, &rows); } @@ -859,7 +859,7 @@ fn dropHighlights(p: *Pardes, f: *File.State) void { /// text that is no file (a list, a scratch). fn addressOf(arena: std.mem.Allocator, tp: *const Pane) []const u8 { const f = tp.file orelse return ""; - if (f.output == null and !std.mem.startsWith(u8, std.fs.path.basename(f.path), "+")) return f.path; + if (f.output == null and !std.mem.startsWith(u8, std.Io.Dir.path.basename(f.path), "+")) return f.path; return std.fmt.allocPrint(arena, config.pane_addr ++ "{d}", .{tp.serial}) catch ""; } @@ -937,7 +937,7 @@ fn writePlacesRows(p: *Pardes, q: *Query, out: *std.ArrayList(u8), rows: *std.Ar const head = std.mem.trim(u8, f.content[head_ls..head_le], " \t\r"); // Its address too, `rel:line`, in the column the hits' are. var hb: [8192]u8 = undefined; - const address = std.fmt.bufPrint(&hb, "{s}:{d}", .{ rel, decls[di].start_line + 1 }) catch ""; + const address = std.fmt.bufPrint(&hb, "{s}:{d}", .{ rel[0..@min(rel.len, 4096)], decls[di].start_line + 1 }) catch unreachable; // 4096 and a line fit 8192 const gutter = @max(width, address.len) + 2; const shown = head[0..@min(head.len, hb.len -| gutter)]; @memset(hb[address.len..gutter], ' '); @@ -975,9 +975,9 @@ fn makeTextRows(p: *Pardes, id: usize, oid: usize, full: bool) !void { if (set.started and set.from == rp.serial) { if (from > 0) { var hb: [64]u8 = undefined; - try noteRow(p, q, &out, &rows, std.fmt.bufPrint(&hb, " ... {d} places before these", .{from}) catch " ..."); + try noteRow(p, q, &out, &rows, std.fmt.bufPrint(&hb, " ... {d} places before these", .{from}) catch unreachable); // a usize fits } - try writePlacesRows(p, q, &out, &rows, owner, std.fs.path.dirname(rp.file.?.path) orelse "/", from, &budget); + try writePlacesRows(p, q, &out, &rows, owner, std.Io.Dir.path.dirname(rp.file.?.path) orelse "/", from, &budget); } if (q.more) try noteRow(p, q, &out, &rows, " ... and more: the count says how many"); setRows(p, rp, &out, &rows); @@ -1055,11 +1055,11 @@ fn makeAllRows(p: *Pardes, id: usize) !void { q.total += set.hits.items.len; q.more = q.more or !set.complete(); var hb: [600]u8 = undefined; - const name = if (tp.file) |f| Names.relative(f.path, std.fs.path.dirname(rp.file.?.path) orelse "") else ""; - const head = std.fmt.bufPrint(&hb, config.pane_addr ++ "{d} {s} ({d})", .{ tp.serial, name[0..@min(name.len, 500)], set.hits.items.len }) catch ""; + const name = if (tp.file) |f| Names.relative(f.path, std.Io.Dir.path.dirname(rp.file.?.path) orelse "") else ""; + const head = std.fmt.bufPrint(&hb, config.pane_addr ++ "{d} {s} ({d})", .{ tp.serial, name[0..@min(name.len, 500)], set.hits.items.len }) catch unreachable; // 500 and 44 fit 600 try q.items.append(p.gpa, .{ .kind = .header, .serial = tp.serial }); try writeRow(p, &out, &rows, head, .{ .kind = .context, .declaration = true, .path = @constCast(addressOf(p.scratch.allocator(), tp)), .at = .{}, .location_end = 0, .code_start = 0 }); - try writePlacesRows(p, q, &out, &rows, tp, std.fs.path.dirname(rp.file.?.path) orelse "/", 0, &budget); + try writePlacesRows(p, q, &out, &rows, tp, std.Io.Dir.path.dirname(rp.file.?.path) orelse "/", 0, &budget); } if (budget == 0) try noteRow(p, q, &out, &rows, " ... and more: the count says how many"); setRows(p, rp, &out, &rows); @@ -1088,7 +1088,7 @@ fn countCurrent(q: *Query) void { fn makeNameRows(p: *Pardes, id: usize) !void { const rp = p.panes[id].?; const q = rp.query.?; - const dir = std.fs.path.dirname(rp.file.?.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(rp.file.?.path) orelse "/"; q.items.clearRetainingCapacity(); var out: std.ArrayList(u8) = .empty; defer out.deinit(p.gpa); @@ -1116,7 +1116,7 @@ fn makeNameRows(p: *Pardes, id: usize) !void { meta.path = @constCast(if (t.path.len > 0 and t.path[0] == '/') t.path else std.fmt.bufPrint(&pathbuf, "{s}/{s}", .{ std.mem.trimEnd(u8, dir, "/"), t.path }) catch t.path); meta.at = t.at; }, - .panes => meta.path = @constCast(std.fmt.bufPrint(&pathbuf, config.pane_addr ++ "{d}", .{cand.ref}) catch ""), + .panes => meta.path = @constCast(std.fmt.bufPrint(&pathbuf, config.pane_addr ++ "{d}", .{cand.ref}) catch unreachable), // short .symbols => { const owner = p.panes[p.paneBySerial(q.owner) orelse 0]; meta.path = @constCast(if (owner) |o| addressOf(p.scratch.allocator(), o) else ""); @@ -1161,7 +1161,7 @@ fn makeNameRows(p: *Pardes, id: usize) !void { fn makeGrepRows(p: *Pardes, id: usize, full: bool) !void { const rp = p.panes[id].?; const q = rp.query.?; - const dir = std.fs.path.dirname(rp.file.?.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(rp.file.?.path) orelse "/"; const at: usize = @min(q.grep_at, q.found.items.len -| 1); // nothing current before these rows: the first one's shown once it is const shown = q.current != null; @@ -1175,7 +1175,7 @@ fn makeGrepRows(p: *Pardes, id: usize, full: bool) !void { const hi = if (full) q.found.items.len else @min(q.found.items.len, lo + live_rows); if (lo > 0) { var hb: [64]u8 = undefined; - try noteRow(p, q, &out, &rows, std.fmt.bufPrint(&hb, " ... {d} lines before these", .{lo}) catch " ..."); + try noteRow(p, q, &out, &rows, std.fmt.bufPrint(&hb, " ... {d} lines before these", .{lo}) catch unreachable); // a usize fits } var current: ?usize = null; var sh: Shades = .{}; @@ -1204,7 +1204,7 @@ fn makeGrepRows(p: *Pardes, id: usize, full: bool) !void { } if (hi < q.found.items.len) { var hb: [64]u8 = undefined; - try noteRow(p, q, &out, &rows, std.fmt.bufPrint(&hb, " ... {d} lines after these", .{q.found.items.len - hi}) catch " ..."); + try noteRow(p, q, &out, &rows, std.fmt.bufPrint(&hb, " ... {d} lines after these", .{q.found.items.len - hi}) catch unreachable); // a usize fits } if (p.stream.target == rp.serial and p.stream.state == .capped) try noteRow(p, q, &out, &rows, " ... stopped at 2000 lines: More in the tag goes on"); try skippedRow(p, q, rp, &out, &rows); @@ -1223,7 +1223,7 @@ fn skippedRow(p: *Pardes, q: *Query, rp: *Pane, out: *std.ArrayList(u8), rows: * const n = p.stream.skipped; if (p.stream.target != rp.serial or n == 0) return; var hb: [96]u8 = undefined; - try noteRow(p, q, out, rows, std.fmt.bufPrint(&hb, " {d} director{s} skipped: permission denied", .{ n, if (n == 1) "y" else "ies" }) catch " directories skipped"); + try noteRow(p, q, out, rows, std.fmt.bufPrint(&hb, " {d} director{s} skipped: permission denied", .{ n, if (n == 1) "y" else "ies" }) catch unreachable); // a usize and 40 fit 96 } /// `k` for a Grep: the current row's line among all the lines sent. @@ -1291,7 +1291,7 @@ pub fn fillList(p: *Pardes, owner_id: usize, source: Source, rows: []const u8) v const qid = id orelse return; const rp = p.panes[qid].?; const q = rp.query.?; - const copy = p.gpa.dupe(u8, rows) catch return; + const copy = p.gpa.dupe(u8, rows) catch |err| return p.reportError(qid, "search", err); p.gpa.free(q.lsp_rows); q.lsp_rows = copy; const line = lineOne(rp.file.?.content); @@ -1320,7 +1320,7 @@ pub fn fillList(p: *Pardes, owner_id: usize, source: Source, rows: []const u8) v fn makeListRows(p: *Pardes, id: usize, pat: []const u8) !void { const rp = p.panes[id].?; const q = rp.query.?; - const dir = std.fs.path.dirname(rp.file.?.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(rp.file.?.path) orelse "/"; q.items.clearRetainingCapacity(); var out: std.ArrayList(u8) = .empty; defer out.deinit(p.gpa); @@ -1537,7 +1537,7 @@ pub fn step(p: *Pardes, id: usize, delta: i32) void { const in_window = for (q.items.items) |it| { if (it.kind == .hit and it.hit == q.grep_at) break true; } else false; - if (!in_window) makeGrepRows(p, id, q.frozen) catch {}; + if (!in_window) makeGrepRows(p, id, q.frozen) catch |err| p.reportError(id, "search", err); for (q.items.items, 0..) |it, i| if (it.kind == .hit and it.hit == q.grep_at) return setCurrent(p, id, i, true); return; } @@ -1558,7 +1558,7 @@ fn blankPreview(p: *Pardes, qid: usize) void { const pane = p.panes[pid].?; const f = &pane.file.?; if (f.content.len == 0) return; - const dir = std.fs.path.dirname(p.panes[qid].?.file.?.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(p.panes[qid].?.file.?.path) orelse "/"; const path = std.fmt.allocPrint(p.gpa, "{s}/{s}", .{ dir, config.preview_buffer }) catch return; const empty = p.gpa.alloc(u8, 0) catch { p.gpa.free(path); @@ -1657,7 +1657,7 @@ pub fn isPreview(p: *Pardes, pane: *const Pane) ?usize { fn makePreview(p: *Pardes, qid: usize, rows: u16, giver: usize) ?usize { const rp = p.panes[qid].?; const free = p.freeSlot() orelse return null; - const dir = std.fs.path.dirname(rp.file.?.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(rp.file.?.path) orelse "/"; const content = p.gpa.dupe(u8, "") catch return null; const np = Output.open(p, free, dir, .preview, "", content) catch { p.gpa.free(content); @@ -1721,7 +1721,7 @@ fn displayPreview(p: *Pardes, qid: usize, path: []const u8, at: look.Spot) void .refs, .defs, .impls, .diagnostics => if (pane.places.from != qp.serial or !pane.places.shows(pane)) { var hits: std.ArrayList(Places.Hit) = .empty; defer hits.deinit(p.gpa); - const dir = std.fs.path.dirname(qp.file.?.path) orelse "/"; + const dir = std.Io.Dir.path.dirname(qp.file.?.path) orelse "/"; const nlines = File.nlines(p.gpa, f); var pathbuf: [4096 + 8]u8 = undefined; var lines = std.mem.splitScalar(u8, q.lsp_rows, '\n'); @@ -1793,12 +1793,12 @@ pub fn land(p: *Pardes, id: usize, row: ?usize) void { // The whole list now, once, every place found: a result from here. if (set.started and set.from == rp.serial) { set.fill(p, owner, std.math.maxInt(usize), @import("regexp.zig").Regex.budget); - makeTextRows(p, id, oid, true) catch {}; + makeTextRows(p, id, oid, true) catch |err| p.reportError(id, "search", err); } if (set.started and set.from == rp.serial) { if (set.literal) { var escaped: std.ArrayList(u8) = .empty; - normal.appendSearchLiteral(&escaped, p.scratch.allocator(), set.pattern) catch {}; + normal.appendSearchLiteral(&escaped, p.scratch.allocator(), set.pattern) catch |err| return p.reportError(id, "search", err); p.registers.put(p.gpa, '/', escaped.items, 0, 1, true); } else p.registers.put(p.gpa, '/', set.pattern, 0, 1, true); p.registers.last_search = '/'; @@ -1857,7 +1857,7 @@ pub fn land(p: *Pardes, id: usize, row: ?usize) void { return; }; // A Grep's whole list, now it is a result. - if (q.source == .grep) makeGrepRows(p, id, true) catch {}; + if (q.source == .grep) makeGrepRows(p, id, true) catch |err| p.reportError(id, "search", err); var buf: [4096 + 64]u8 = undefined; const address = if (meta.at.line > 0) std.fmt.bufPrint(&buf, "{s}:{d}:{d}", .{ meta.path, meta.at.line, meta.at.col }) catch meta.path @@ -2063,8 +2063,8 @@ pub fn rowAddress(pane: *const Pane, row: usize, col: usize, buf: []u8) ?[]const /// The tag's start for a query pane: its name and where it is, `+Search /// 3/27`, `0` with nothing found, `+` while it still counts. -pub fn tagPrefix(q: *const Query, arena: std.mem.Allocator, path: []const u8) ![]const u8 { - const name = std.fs.path.basename(path); +pub fn tagPrefix(q: *const Query, arena: std.mem.Allocator, path: []const u8) error{OutOfMemory}![]const u8 { + const name = std.Io.Dir.path.basename(path); const more = if (q.more and !q.frozen) "+" else ""; if (q.total == 0) return std.fmt.allocPrint(arena, "{s} 0{s}", .{ name, more }); if (q.k == 0) return std.fmt.allocPrint(arena, "{s} {d}{s}", .{ name, q.total, more }); @@ -2297,11 +2297,11 @@ test "a / query: Enter lands and freezes, the register filled, n and N step sile /// A test's file pane in `tmp`, named `name`, holding `text`. fn testFileIn(p: *Pardes, tmp: *std.testing.TmpDir, name: []const u8, text: []const u8) !*Pane { try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = text }); - var base_buf: [std.fs.max_path_bytes]u8 = undefined; + var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; const dir = base_buf[0..try tmp.dir.realPath(std.testing.io, &base_buf)]; const pane = try p.setTestFile(text); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ dir, name }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ dir, name }); return pane; } @@ -2705,7 +2705,7 @@ test "a row's address is the shortest path a Look from the query pane resolves: defer tmp.cleanup(); try tmp.dir.createDirPath(std.testing.io, "q/sub"); for ([_][]const u8{ "q/sub/deep.txt", "up.txt" }) |name| try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = "one\ntwo\n" }); - var root_buf: [std.fs.max_path_bytes]u8 = undefined; + var root_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; const root = root_buf[0..try tmp.dir.realPath(std.testing.io, &root_buf)]; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 40 }); defer p.deinit(); @@ -2718,7 +2718,7 @@ test "a row's address is the shortest path a Look from the query pane resolves: fillList(p, 0, .refs, answer); const qp = p.panes[queryPane(p).?].?; const f = &qp.file.?; - const dir = std.fs.path.dirname(f.path).?; + const dir = std.Io.Dir.path.dirname(f.path).?; var lines = std.mem.splitScalar(u8, f.content, '\n'); var seen: std.ArrayList([]const u8) = .empty; defer seen.deinit(std.testing.allocator); diff --git a/src/Stream.zig b/src/Stream.zig index 6a7dc324..2641fc73 100644 --- a/src/Stream.zig +++ b/src/Stream.zig @@ -491,16 +491,16 @@ pub fn cancelTask(s: *Stream) void { /// listing of the files (`.files`), under `dir`. The generation before it /// is over (its worker canceled, its batches dropped when they come); /// `typed`, it starts once the typing pauses, else at the next step. -pub fn query(p: *Pardes, target: u32, kind: Kind, pattern: []const u8, dir: []const u8, how: enum { typed, now }) void { +pub fn query(p: *Pardes, target: u32, kind: Kind, pattern: []const u8, dir: []const u8, how: enum { typed, now }) error{OutOfMemory}!void { const s = &p.stream; s.cancelTask(); s.gen +%= 1; s.kind = kind; s.target = target; s.pattern.clearRetainingCapacity(); - s.pattern.appendSlice(p.gpa, pattern) catch return; + try s.pattern.appendSlice(p.gpa, pattern); s.dir.clearRetainingCapacity(); - s.dir.appendSlice(p.gpa, dir) catch return; + try s.dir.appendSlice(p.gpa, dir); s.skipped = 0; s.state = .waiting; s.due_ns = if (how == .typed) p.clock.now_ns + debounce_ns else p.clock.now_ns; @@ -858,7 +858,7 @@ const Worker = struct { } /// Whether the cap ended it (on the loop). - fn walkDir(w: *Worker, dir: std.Io.Dir, prefix: []const u8, depth: usize) anyerror!bool { + fn walkDir(w: *Worker, dir: std.Io.Dir, prefix: []const u8, depth: usize) error{ Canceled, OutOfMemory, Refused }!bool { try w.io.checkCancel(); var arena: std.heap.ArenaAllocator = .init(w.gpa); defer arena.deinit(); @@ -991,7 +991,7 @@ const Worker = struct { if (w.job.kind == .files) { // a dot-file is passed over, as the walk passes over // dot-directories - if (std.mem.startsWith(u8, std.fs.path.basename(line.items), ".")) continue; + if (std.mem.startsWith(u8, std.Io.Dir.path.basename(line.items), ".")) continue; if (try w.file(w.shown(line.items))) { cut = true; break :read; @@ -1170,7 +1170,7 @@ test "Stream: a stale generation's rows never land in the query pane, however tw var name_buf: [64]u8 = undefined; for (0..files) |i| { const name = try std.fmt.bufPrint(&name_buf, "d{d:0>2}/f{d:0>3}.txt", .{ i / 10, i }); - try tmp.dir.createDirPath(testing.io, std.fs.path.dirname(name).?); + try tmp.dir.createDirPath(testing.io, std.Io.Dir.path.dirname(name).?); try tmp.dir.writeFile(testing.io, .{ .sub_path = name, .data = "a needle line\nsome hay here\nneedle again\nhay hay\nmore hay\n" }); } const root = root_buf[0..try tmp.dir.realPath(testing.io, &root_buf)]; @@ -1178,7 +1178,7 @@ test "Stream: a stale generation's rows never land in the query pane, however tw defer p.deinit(); const pane = try p.setTestFile("x\n"); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ root, "main.txt" }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ root, "main.txt" }); p.advance(1); var shell: TestShell = .init(); shell.attach(p); @@ -1204,17 +1204,17 @@ test "Stream: a stale generation's rows never land in the query pane, however tw const b = if (round % 2 == 0) "hay" else "needle"; q.found.clearRetainingCapacity(); q.found_bytes.clearRetainingCapacity(); - query(p, qp.serial, .grep, a, root, .now); + try query(p, qp.serial, .grep, a, root, .now); p.update(.tick); for (0..round % 3) |_| shell.pump(p); var rogue: Rogue = .{ .q = &shell.q, .gen = p.stream.gen }; q.found.clearRetainingCapacity(); q.found_bytes.clearRetainingCapacity(); if (round % 4 == 3) { - query(p, qp.serial, .grep, b, root, .typed); + try query(p, qp.serial, .grep, b, root, .typed); try testing.expectEqual(State.waiting, p.stream.state); p.advance(p.clock.now_ns + debounce_ns + std.time.ns_per_ms); - } else query(p, qp.serial, .grep, b, root, .now); + } else try query(p, qp.serial, .grep, b, root, .now); try testing.expect(p.stream.gen != rogue.gen); const thread = try std.Thread.spawn(.{}, Rogue.run, .{&rogue}); const finished = shell.finish(p, 20_000); @@ -1255,7 +1255,7 @@ test "Stream: the listing of files for Find on a worker, a cap of hits stops the defer p.deinit(); const pane = try p.setTestFile("x\n"); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ root, "main.txt" }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ root, "main.txt" }); p.advance(1); p.stream.engine = .walk; // No host workers: the listing runs on the loop at the next tick. @@ -1368,7 +1368,7 @@ test "Stream: a Grep stops at its 2000 lines and waits; More in the query pane's defer p.deinit(); const pane = try p.setTestFile("x\n"); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ root, "main.txt" }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ root, "main.txt" }); p.advance(1); var shell: TestShell = .init(); shell.attach(p); @@ -1418,7 +1418,7 @@ test "Stream: a Grep's rows recoloured are made again, never written, and a dump defer p.deinit(); const pane = try p.setTestFile(text.items); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ root, "c.zig" }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ root, "c.zig" }); var shell: TestShell = .init(); shell.attach(p); defer { @@ -1488,7 +1488,7 @@ test "Stream: a Grep's rows are coloured as their file's language colours them, // the file open in the pane that asks: its text painted, not the disk's const pane = try p.setTestFile(text); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ root, "c.zig" }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ root, "c.zig" }); var shell: TestShell = .init(); shell.attach(p); defer { |
