fix: make open_recent_projects run async
This commit is contained in:
parent
7d7a45f539
commit
d53a24a1d2
2 changed files with 22 additions and 6 deletions
|
@ -27,10 +27,12 @@ pub fn deinit(palette: *Type) void {
|
|||
palette.allocator.free(entry.label);
|
||||
}
|
||||
|
||||
pub fn load_entries(palette: *Type) !usize {
|
||||
const rsp = try project_manager.request_recent_projects(palette.allocator);
|
||||
defer palette.allocator.free(rsp.buf);
|
||||
var iter: []const u8 = rsp.buf;
|
||||
pub fn load_entries_with_args(palette: *Type, ctx: command.Context) !usize {
|
||||
var items_cbor: []const u8 = undefined;
|
||||
if (!(cbor.match(ctx.args.buf, .{ "PRJ", "recent_projects", tp.extract_cbor(&items_cbor) }) catch false))
|
||||
return error.InvalidRecentProjects;
|
||||
|
||||
var iter: []const u8 = items_cbor;
|
||||
var len = try cbor.decodeArrayHeader(&iter);
|
||||
while (len > 0) : (len -= 1) {
|
||||
var name_: []const u8 = undefined;
|
||||
|
|
|
@ -413,6 +413,9 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
|||
return;
|
||||
}
|
||||
|
||||
if (try m.match(.{ "PRJ", "recent_projects", tp.more })) // async recent projects request
|
||||
return self.enter_overlay_mode_with_args(@import("mode/overlay/open_recent_project.zig").Type, .{ .args = m });
|
||||
|
||||
if (try m.match(.{ "PRJ", tp.more })) // drop late project manager query responses
|
||||
return;
|
||||
|
||||
|
@ -684,6 +687,17 @@ fn enter_overlay_mode(self: *Self, mode: type) command.Result {
|
|||
refresh_hover();
|
||||
}
|
||||
|
||||
fn enter_overlay_mode_with_args(self: *Self, mode: type, ctx: command.Context) command.Result {
|
||||
command.executeName("disable_fast_scroll", .{}) catch {};
|
||||
command.executeName("disable_jump_mode", .{}) catch {};
|
||||
if (self.mini_mode_) |_| try cmds.exit_mini_mode(self, .{});
|
||||
if (self.input_mode_outer_) |_| try cmds.exit_overlay_mode(self, .{});
|
||||
self.input_mode_outer_ = self.input_mode_;
|
||||
self.input_mode_ = try mode.create_with_args(self.allocator, ctx);
|
||||
if (self.input_mode_) |*m| m.run_init();
|
||||
refresh_hover();
|
||||
}
|
||||
|
||||
fn get_input_mode(self: *Self, mode_name: []const u8) !Mode {
|
||||
return keybind.mode(mode_name, self.allocator, .{});
|
||||
}
|
||||
|
@ -914,8 +928,8 @@ const cmds = struct {
|
|||
}
|
||||
pub const open_recent_meta: Meta = .{ .description = "Open recent" };
|
||||
|
||||
pub fn open_recent_project(self: *Self, _: Ctx) Result {
|
||||
return self.enter_overlay_mode(@import("mode/overlay/open_recent_project.zig").Type);
|
||||
pub fn open_recent_project(_: *Self, _: Ctx) Result {
|
||||
try project_manager.request_recent_projects();
|
||||
}
|
||||
pub const open_recent_project_meta: Meta = .{ .description = "Open project" };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue