fix: send sigterm to languages servers on exit
Not all language servers willingly exit if we just close stdin. Eventually we will follow the protocol's shutdown process, but for now we just send a sigterm.
This commit is contained in:
parent
55e99fe958
commit
9eb6dd3be4
3 changed files with 19 additions and 3 deletions
|
@ -20,8 +20,8 @@
|
|||
.hash = "1220a7cf5f59b61257993bc5b02991ffc523d103f66842fa8d8ab5c9fdba52799340",
|
||||
},
|
||||
.thespian = .{
|
||||
.url = "https://github.com/neurocyte/thespian/archive/7d441d3bcfaee66b313a333d440deac2e26f8c2a.tar.gz",
|
||||
.hash = "12206c348bbfb59dcbef2dd3ee5728ad9e26ae925d664eb82cd47b40d91fe6c7a063",
|
||||
.url = "https://github.com/neurocyte/thespian/archive/9be51bb18aae4ff43ffcac649d540a7b4441e4b8.tar.gz",
|
||||
.hash = "1220b78192e49c81dde3d0810985e54be703a192fc5185d2da56929baea0b5186e74",
|
||||
},
|
||||
.themes = .{
|
||||
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-69be8cd05fddcbc2a3ca2dec4abe6b8d07ed65b1/flow-themes.tar.gz",
|
||||
|
|
16
src/LSP.zig
16
src/LSP.zig
|
@ -22,6 +22,11 @@ pub fn deinit(self: *Self) void {
|
|||
self.pid.deinit();
|
||||
}
|
||||
|
||||
pub fn term(self: *Self) void {
|
||||
self.pid.send(.{"term"}) catch {};
|
||||
self.pid.deinit();
|
||||
}
|
||||
|
||||
pub fn send_request(self: Self, a: std.mem.Allocator, method: []const u8, m: anytype) error{Exit}!tp.message {
|
||||
// const frame = tracy.initZone(@src(), .{ .name = module_name ++ ".send_request" });
|
||||
// defer frame.deinit();
|
||||
|
@ -107,6 +112,14 @@ const Process = struct {
|
|||
}
|
||||
}
|
||||
|
||||
fn term(self: *Process) tp.result {
|
||||
if (self.sp) |*sp| {
|
||||
defer self.sp = null;
|
||||
try sp.term();
|
||||
self.write_log("### terminated ###\n", .{});
|
||||
}
|
||||
}
|
||||
|
||||
fn start(self: *Process) tp.result {
|
||||
const frame = tracy.initZone(@src(), .{ .name = module_name ++ " start" });
|
||||
defer frame.deinit();
|
||||
|
@ -137,6 +150,9 @@ const Process = struct {
|
|||
} else if (try m.match(.{"close"})) {
|
||||
self.write_log("### LSP close ###\n", .{});
|
||||
try self.close();
|
||||
} else if (try m.match(.{"term"})) {
|
||||
self.write_log("### LSP terminated ###\n", .{});
|
||||
try self.term();
|
||||
} else if (try m.match(.{ self.sp_tag, "stdout", tp.extract(&bytes) })) {
|
||||
self.handle_output(bytes) catch |e| return tp.exit_error(e);
|
||||
} else if (try m.match(.{ self.sp_tag, "term", tp.extract(&err), tp.extract(&code) })) {
|
||||
|
|
|
@ -45,7 +45,7 @@ pub fn deinit(self: *Self) void {
|
|||
var i = self.language_servers.iterator();
|
||||
while (i.next()) |p| {
|
||||
self.a.free(p.key_ptr.*);
|
||||
p.value_ptr.*.deinit();
|
||||
p.value_ptr.*.term();
|
||||
}
|
||||
for (self.files.items) |file| self.a.free(file.path);
|
||||
self.files.deinit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue