diff options
Diffstat (limited to 'dev/Inbox.zig')
| -rw-r--r-- | dev/Inbox.zig | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/dev/Inbox.zig b/dev/Inbox.zig index ed3a9835..aac1f7a1 100644 --- a/dev/Inbox.zig +++ b/dev/Inbox.zig @@ -23,8 +23,6 @@ pub const Msg = union(enum) { kind_job: *KindJob, files_changed, fs_ready, - /// The daemon asks for the window again (`pardes-gui --attach`). - window, /// A shell a dead session left, its pty's master (Adopt); pid 0 is /// the last of them told. adopted: struct { pid: libc.pid_t, fd: c_int }, @@ -44,7 +42,7 @@ pub const Msg = union(enum) { .adopted => |a| if (a.fd >= 0) { _ = libc.close(a.fd); }, - .eof, .files_changed, .fs_ready, .window => {}, + .eof, .files_changed, .fs_ready => {}, } } }; @@ -264,6 +262,9 @@ pub fn close(q: *Inbox) void { } pub fn deinit(q: *Inbox) void { + // The query in flight ends first: what it still delivers is dropped. + if (q.lsp_task) |*t| t.future.cancel(q.io); + q.lsp_task = null; q.close(); std.debug.assert(q.waiting == 0); } @@ -310,6 +311,23 @@ pub fn startLsp(q: *Inbox, core: *pardes.Pardes, e: Lsp.Request) void { Lsp.start(q.io, q.lsp_allocator, core, &q.lsp_task, e, q, pushLspRows); } +/// A language server's answer or status line taken off the queue, to the +/// core (whichever frontend took it). +pub fn landLsp(q: *Inbox, core: *pardes.Pardes, m: Msg) void { + switch (m) { + .lsp => |l| { + core.update(.{ .lsp_resp = .{ .id = l.id, .rows = l.rows } }); + if (l.rows) |rows| q.lsp_allocator.free(rows); + }, + .lsp_status => |text| { + var mbuf: [256]u8 = undefined; + core.setStatus(.at(core.view().active), pardes.Messages.Message.stamp(&mbuf, "lsp", text)); + q.lsp_allocator.free(text); + }, + else => unreachable, + } +} + fn pushLspRows(ctx: ?*anyopaque, id: u32, rows: ?[]u8) void { const q: *Inbox = @ptrCast(@alignCast(ctx orelse return)); q.push(.{ .lsp = .{ .id = id, .rows = rows } }); |
