diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-27 20:32:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-27 20:32:29 -0300 |
| commit | f65aaf7c569f3238b15e6e7bb0d3c28ffb244c69 (patch) | |
| tree | 52038152bfc588f526960a6d43e465bb0fd36fd4 /dev/lsp/lsp_client.zig | |
| parent | 56f49018ffb9d5b29989d349aefaf6f9e65cf25e (diff) | |
| download | pardes-f65aaf7c569f3238b15e6e7bb0d3c28ffb244c69.tar.gz pardes-f65aaf7c569f3238b15e6e7bb0d3c28ffb244c69.zip | |
Fix macOS tag rendering and cancel LSP preload on exit
Hide retired tag layers and draw every row of live compact layers, including picker rows and their caret. Cancel the language-server opener with the rest of the inbox on shutdown and let the preload handshake unwind while keeping query startup protected.
Verified AppKit picker rendering and retirement, PDF and image rasters, and shutdown with a stalled language server.
Diffstat (limited to 'dev/lsp/lsp_client.zig')
| -rw-r--r-- | dev/lsp/lsp_client.zig | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/dev/lsp/lsp_client.zig b/dev/lsp/lsp_client.zig index 10a3a3ce..9264a690 100644 --- a/dev/lsp/lsp_client.zig +++ b/dev/lsp/lsp_client.zig @@ -784,7 +784,7 @@ pub fn open(io: std.Io, arena: std.mem.Allocator, req: lsp.Req) Err!void { return; } var tr: Trace = .{}; - _ = try ensure(c, io, si, arena, req, &tr); + _ = try ensure(c, io, si, arena, req, &tr, false); var uri: std.ArrayList(u8) = .empty; try uriOf(&uri, arena, req.path); try syncDoc(c, io, si, arena, uri.items, req.source); @@ -806,7 +806,7 @@ fn answer(io: std.Io, arena: std.mem.Allocator, si: usize, req: lsp.Req, out: *s const c = &conns[si]; try c.mu.lock(io); defer c.mu.unlock(io); - const g = try ensure(c, io, si, arena, req, tr); + const g = try ensure(c, io, si, arena, req, tr, true); const before = out.end; try attempt(c, io, si, arena, req, out, tr, g); // An empty answer can beat the startup progress notification onto the wire. @@ -2024,7 +2024,7 @@ fn findBin(name: []const u8, path: []const u8, home: []const u8, buf: *[4096:0]u /// Spawn-or-return, and tell an existing server about a new project root. /// Returns the generation the caller's whole query is bound to. -fn ensure(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, req: lsp.Req, tr: *Trace) Err!u32 { +fn ensure(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, req: lsp.Req, tr: *Trace, protect_startup: bool) Err!u32 { c.si = si; if (c.state == .disabled) { tr.note("STOP: {s} is disabled for this session (no binary; set {s})", .{ specs[si].name, specs[si].env }); @@ -2155,14 +2155,16 @@ fn ensure(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, req: lsp.Re post(si, .always, "{s} starting — {s}", .{ specs[si].name, root }); tr.note("spawned {s} (pid {d}) at {s}", .{ specs[si].name, pid, root }); - // A start runs to the end however soon the query that began it is - // canceled: killing a half-started server would only make the next - // query start it again. The cancel lands at the next wait instead. - const protection = io.swapCancelProtection(.blocked); - const started = handshake(c, io, arena, root); - _ = io.swapCancelProtection(protection); + // A replaced query leaves its startup to the next query. The file-open + // worker is canceled only during teardown and can abandon its handshake. + const started = if (protect_startup) started: { + const protection = io.swapCancelProtection(.blocked); + defer _ = io.swapCancelProtection(protection); + break :started handshake(c, io, arena, root); + } else handshake(c, io, arena, root); started catch |e| { shutdownIf(c, io, g); + if (e == error.Canceled) return e; // NOT a session disable. A handshake that misses the deadline is // routinely environmental — a rustup shim deciding to download the // project's pinned toolchain before launching the real server was |
