diff options
Diffstat (limited to 'test/session.zig')
| -rw-r--r-- | test/session.zig | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/test/session.zig b/test/session.zig index 87bf784e..4919c0a3 100644 --- a/test/session.zig +++ b/test/session.zig @@ -34,6 +34,11 @@ pub const Session = struct { /// What the language words' questions are asked of their servers /// through (initLanguage); none, and they go unanswered. languages: ?std.Io = null, + /// Kinds' jobs taken as a host's worker takes them and held, not run, + /// until `releaseJobs`: a job under way across what a test does + /// meanwhile (a reload). + hold_jobs: bool = false, + held: std.ArrayList(*pardes.host_io.KindJob) = .empty, /// A session showing one file pane holding `text`, keeping what outlives /// it in a database in memory (src/Db.zig). @@ -87,8 +92,8 @@ pub const Session = struct { } pub fn deinit(s: *Session) void { + s.held.deinit(pardesOf(s).gpa); pardesOf(s).deinit(); - pardes.Addon.unloadAll(); s.arena.deinit(); } @@ -229,12 +234,26 @@ pub const Session = struct { .save_file, .save_text => s.saved += 1, // Into the session's state (a database in memory, or its file). .write_dump => pardes.host_io.writeDump(pardesOf(s), pardesOf(s).dump_out.?), - .addon => |a| pardes.Addon.perform(pardesOf(s), a.op, a.pane, a.arg.slice()), + .addon => pardesOf(s).perform(e), + // A kind's job, here and at once, as the host's worker would; + // held while a test holds them (`hold_jobs`). + .job => |j| if (!s.hold_jobs) pardesOf(s).perform(e) else if (pardes.host_io.KindJob.take(pardesOf(s), j.pane, j.serial, j.token)) |taken| s.held.append(pardesOf(s).gpa, taken) catch taken.drop(), .lsp => |q| if (s.languages) |io| s.askServer(io, .{ .id = q.id, .kind = q.kind, .pane = q.pane, .offset = q.offset, .arg = q.arg.slice() }), else => {}, }; } + /// The jobs held, run now and answered as the host's workers would. + pub fn releaseJobs(s: *Session) void { + s.hold_jobs = false; + for (s.held.items) |j| { + j.run(); + j.land(pardesOf(s)); + } + s.held.clearRetainingCapacity(); + s.drain(); + } + /// A language word's question asked of its server as a host asks it /// (host_io.Lsp), here and at once: its answer the core's next event. fn askServer(s: *Session, io: std.Io, req: pardes.host_io.Lsp.Request) void { |
