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:
		
							parent
							
								
									739b2a776f
								
							
						
					
					
						commit
						fc3224137d
					
				
					 3 changed files with 114 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue