fix: remove blocking project manager call on startup

closes #214

The blocking call get_mru_postion to the project mananger may cause
a deadlock if the project manager has not started running yet.
This commit is contained in:
CJ van den Berg 2025-03-25 15:04:23 +01:00
parent 739b2a776f
commit fc3224137d
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 114 additions and 12 deletions

View file

@ -232,16 +232,13 @@ pub fn update_mru(file_path: []const u8, row: usize, col: usize, ephemeral: bool
return send(.{ "update_mru", project, file_path, row, col });
}
pub fn get_mru_position(allocator: std.mem.Allocator, file_path: []const u8) (ProjectManagerError || ProjectError || CallError || cbor.Error)!?Project.FilePos {
const frame = tracy.initZone(@src(), .{ .name = "get_mru_position" });
defer frame.deinit();
pub fn get_mru_position(allocator: std.mem.Allocator, file_path: []const u8, ctx: anytype) (ProjectManagerError || ProjectError)!void {
const project = tp.env.get().str("project");
if (project.len == 0)
return error.NoProject;
const rsp = try (try get()).pid.call(allocator, request_timeout, .{ "get_mru_position", project, file_path });
defer allocator.free(rsp.buf);
var pos: Project.FilePos = undefined;
return if (try cbor.match(rsp.buf, .{ tp.extract(&pos.row), tp.extract(&pos.col) })) pos else null;
const cp = @import("completion.zig");
return cp.send(allocator, (try get()).pid, .{ "get_mru_position", project, file_path }, ctx);
}
const Process = struct {