diff options
Diffstat (limited to 'core/Stream.zig')
| -rw-r--r-- | core/Stream.zig | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/core/Stream.zig b/core/Stream.zig index 5960d249..1f4a7405 100644 --- a/core/Stream.zig +++ b/core/Stream.zig @@ -311,7 +311,7 @@ pub fn takeAhead(p: *Pardes, serial: u32, revision: u32, need_start: usize, need /// workers, and only for a grammar a worker can paint (syntax.readyApart). pub fn paintAhead(p: *Pardes, serial: u32, revision: u32, path: []const u8, content: []const u8, from: usize, to: usize) void { const s = &p.stream; - if (p.host.vtable.search == null or p.fs.serving or to <= from or to > content.len) return; + if (!p.tape.has(p, .search) or p.fs.serving or to <= from or to > content.len) return; const a = s.ahead_for; if (s.ahead.len != 0 and a.serial == serial and a.revision == revision and from >= a.start and to <= a.start + s.ahead.len) return; // A stretch bigger than this (a few lines of a minified file) is not @@ -343,7 +343,7 @@ pub fn paintAhead(p: *Pardes, serial: u32, revision: u32, path: []const u8, cont pub fn askAhead(p: *Pardes) void { const gen = p.stream.ahead_ask orelse return; p.stream.ahead_ask = null; - if (p.host.vtable.search) |f| f(p.host.ctx, gen); + _ = p.tape.host(p, .search, .{gen}); } /// A file's colours for the query rows that show its lines, the whole @@ -355,7 +355,7 @@ pub fn askAhead(p: *Pardes) void { /// one revision of a file. pub fn paintRows(p: *Pardes, path: []const u8) void { const s = &p.stream; - if (s.rows_paint != null or p.host.vtable.search == null) return; + if (s.rows_paint != null or !p.tape.has(p, .search)) return; // Asked while a 9P write is served (a script's Grep): not now, as no // paint is (the write would wait for it to settle); the next step asks. if (p.fs.serving) { @@ -452,7 +452,7 @@ pub fn parseFor(p: *Pardes, id: usize) void { s.parse_next = .{ .serial = pane.serial, .revision = f.revision }; return; } - const workers = p.host.vtable.search != null and !p.fs.serving; + const workers = p.tape.has(p, .search) and !p.fs.serving; if (!workers and f.content.len > 64 << 10) return; const job = TextJob.make(p.gpa, pane.serial, f.revision, 0, f.path, f.content) orelse return; s.gen +%= 1; @@ -478,7 +478,6 @@ fn parseWork(io: std.Io, job: *TextJob, ctx: ?*anyopaque, sink: Sink) void { } fn now() u64 { - if (comptime !filesystem.platform_has_fs) return 0; const t = std.Io.Clock.awake.now(std.Io.Threaded.global_single_threaded.io()); return @intCast(@max(0, t.nanoseconds)); } @@ -559,7 +558,7 @@ pub fn step(p: *Pardes) void { s.state = .searching; // A script's write (whose answer says whether it found anything) and a // host with no workers: done before this returns. - if (p.host.vtable.search != null and !p.fs.serving) p.emit(.{ .search = .{ .gen = s.gen } }) else runHere(p, s.gen, false); + if (p.tape.has(p, .search) and !p.fs.serving) p.emit(.{ .search = .{ .gen = s.gen } }) else runHere(p, s.gen, false); } /// When the core next needs a tick for the stream: the end of the pause. @@ -635,10 +634,6 @@ pub fn runHere(p: *Pardes, gen: u32, comptime in_call: bool) void { }; return; } - if (comptime !filesystem.platform_has_fs) { - p.stream.state = .failed; - return; - } const s = &p.stream; if (gen != s.gen or s.state != .searching) return; const job = makeJob(p.gpa, s) catch |err| { @@ -1163,7 +1158,6 @@ const Rogue = struct { }; test "Stream: a stale generation's rows never land in the query pane, however two generations race (walk and rg)" { - if (comptime !filesystem.platform_has_fs) return; var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); var root_buf: [4096]u8 = undefined; @@ -1243,7 +1237,6 @@ test "Stream: a stale generation's rows never land in the query pane, however tw } test "Stream: the listing of files for Find on a worker, a cap of hits stops the walk on the loop" { - if (comptime !filesystem.platform_has_fs) return; var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); var root_buf: [4096]u8 = undefined; @@ -1273,7 +1266,6 @@ test "Stream: the listing of files for Find on a worker, a cap of hits stops the } test "Stream: a big text's declarations are parsed on a worker, never the loop, and the rows of its / regroup under them" { - if (comptime !filesystem.platform_has_fs) return; const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); defer p.deinit(); var text: std.ArrayList(u8) = .empty; @@ -1312,7 +1304,6 @@ test "Stream: a big text's declarations are parsed on a worker, never the loop, } test "Stream: a scroll's colours are painted ahead on a worker, so PageDown after PageDown parses nothing on the frame" { - if (comptime !filesystem.platform_has_fs or !syntax.enabled) return; const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); defer p.deinit(); var text: std.ArrayList(u8) = .empty; @@ -1355,7 +1346,6 @@ test "Stream: a scroll's colours are painted ahead on a worker, so PageDown afte } test "Stream: a Grep stops at its 2000 lines and waits; More in the query pane's tag goes on" { - if (comptime !filesystem.platform_has_fs) return; var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); var root_buf: [4096]u8 = undefined; @@ -1404,8 +1394,7 @@ test "Stream: a Grep stops at its 2000 lines and waits; More in the query pane's } test "Stream: a Grep's rows recoloured are made again, never written, and a dump of them dropped by an edit loads to its digest" { - if (comptime !filesystem.platform_has_fs) return; - if (!syntax.enabled or !syntax.readyApart("c.zig")) return; + if (!syntax.readyApart("c.zig")) return; var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); // Rows enough that a digest keeps a word for them (walk's blob_min). @@ -1476,8 +1465,7 @@ test "Stream: a Grep's rows recoloured are made again, never written, and a dump } test "Stream: a Grep's rows are coloured as their file's language colours them, the file painted on a worker, the match tint on top" { - if (comptime !filesystem.platform_has_fs) return; - if (!syntax.enabled or !syntax.readyApart("c.zig")) return; + if (!syntax.readyApart("c.zig")) return; var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); const text = "const std = @import(\"std\");\npub fn value() u32 {\n return 42; // value\n}\n"; |
