summaryrefslogtreecommitdiff
path: root/dev/Inbox.zig
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Inbox.zig')
-rw-r--r--dev/Inbox.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/dev/Inbox.zig b/dev/Inbox.zig
index 4df02013..aac1f7a1 100644
--- a/dev/Inbox.zig
+++ b/dev/Inbox.zig
@@ -262,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);
}
@@ -308,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 } });