feat: refresh open_recent palette when the project is done loading the file list
This commit is contained in:
parent
4ca455cbba
commit
67fc1581d3
3 changed files with 16 additions and 10 deletions
|
@ -413,11 +413,11 @@ pub fn walk_tree_entry(self: *Self, file_path: []const u8, mtime: i128) OutOfMem
|
|||
(try self.pending.addOne(self.allocator)).* = .{ .path = try self.allocator.dupe(u8, file_path), .mtime = mtime };
|
||||
}
|
||||
|
||||
pub fn walk_tree_done(self: *Self) OutOfMemoryError!void {
|
||||
pub fn walk_tree_done(self: *Self, parent: tp.pid_ref) OutOfMemoryError!void {
|
||||
self.state.walk_tree = .done;
|
||||
if (self.walker) |pid| pid.deinit();
|
||||
self.walker = null;
|
||||
return self.loaded();
|
||||
return self.loaded(parent);
|
||||
}
|
||||
|
||||
fn merge_pending_files(self: *Self) OutOfMemoryError!void {
|
||||
|
@ -433,7 +433,7 @@ fn merge_pending_files(self: *Self) OutOfMemoryError!void {
|
|||
}
|
||||
}
|
||||
|
||||
fn loaded(self: *Self) OutOfMemoryError!void {
|
||||
fn loaded(self: *Self, parent: tp.pid_ref) OutOfMemoryError!void {
|
||||
inline for (@typeInfo(@TypeOf(self.state)).@"struct".fields) |f|
|
||||
if (@field(self.state, f.name) == .running) return;
|
||||
|
||||
|
@ -449,6 +449,8 @@ fn loaded(self: *Self) OutOfMemoryError!void {
|
|||
self.files.items.len,
|
||||
std.time.milliTimestamp() - self.open_time,
|
||||
});
|
||||
|
||||
parent.send(.{ "PRJ", "open_done", self.name, self.longest_file_path, self.files.items.len }) catch {};
|
||||
}
|
||||
|
||||
pub fn update_mru(self: *Self, file_path: []const u8, row: usize, col: usize) OutOfMemoryError!void {
|
||||
|
@ -1913,13 +1915,13 @@ fn start_walker(self: *Self) void {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn process_git(self: *Self, m: tp.message) (OutOfMemoryError || error{Exit})!void {
|
||||
pub fn process_git(self: *Self, parent: tp.pid_ref, m: tp.message) (OutOfMemoryError || error{Exit})!void {
|
||||
var value: []const u8 = undefined;
|
||||
var path: []const u8 = undefined;
|
||||
if (try m.match(.{ tp.any, tp.any, "workspace_path", tp.null_ })) {
|
||||
self.state.workspace_path = .done;
|
||||
self.start_walker();
|
||||
try self.loaded();
|
||||
try self.loaded(parent);
|
||||
} else if (try m.match(.{ tp.any, tp.any, "workspace_path", tp.extract(&value) })) {
|
||||
if (self.workspace) |p| self.allocator.free(p);
|
||||
self.workspace = try self.allocator.dupe(u8, value);
|
||||
|
@ -1930,19 +1932,19 @@ pub fn process_git(self: *Self, m: tp.message) (OutOfMemoryError || error{Exit})
|
|||
};
|
||||
} else if (try m.match(.{ tp.any, tp.any, "current_branch", tp.null_ })) {
|
||||
self.state.current_branch = .done;
|
||||
try self.loaded();
|
||||
try self.loaded(parent);
|
||||
} else if (try m.match(.{ tp.any, tp.any, "current_branch", tp.extract(&value) })) {
|
||||
if (self.branch) |p| self.allocator.free(p);
|
||||
self.branch = try self.allocator.dupe(u8, value);
|
||||
self.state.current_branch = .done;
|
||||
try self.loaded();
|
||||
try self.loaded(parent);
|
||||
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.extract(&path) })) {
|
||||
self.longest_file_path = @max(self.longest_file_path, path.len);
|
||||
const stat = std.fs.cwd().statFile(path) catch return;
|
||||
(try self.pending.addOne(self.allocator)).* = .{ .path = try self.allocator.dupe(u8, path), .mtime = stat.mtime };
|
||||
} else if (try m.match(.{ tp.any, tp.any, "workspace_files", tp.null_ })) {
|
||||
self.state.workspace_files = .done;
|
||||
try self.loaded();
|
||||
try self.loaded(parent);
|
||||
} else {
|
||||
self.logger_git.err("git", tp.unexpected(m));
|
||||
}
|
||||
|
|
|
@ -341,10 +341,10 @@ const Process = struct {
|
|||
project.walk_tree_entry(path, mtime) catch |e| self.logger.err("walk_tree_entry", e);
|
||||
} else if (try cbor.match(m.buf, .{ "walk_tree_done", tp.extract(&project_directory) })) {
|
||||
if (self.projects.get(project_directory)) |project|
|
||||
project.walk_tree_done() catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
|
||||
project.walk_tree_done(self.parent.ref()) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
|
||||
} else if (try cbor.match(m.buf, .{ "git", tp.extract(&context), tp.more })) {
|
||||
const project: *Project = @ptrFromInt(context);
|
||||
project.process_git(m) catch {};
|
||||
project.process_git(self.parent.ref(), m) catch {};
|
||||
} else if (try cbor.match(m.buf, .{ "update_mru", tp.extract(&project_directory), tp.extract(&path), tp.extract(&row), tp.extract(&col) })) {
|
||||
self.update_mru(project_directory, path, row, col) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
|
||||
} else if (try cbor.match(m.buf, .{ "child", tp.extract(&project_directory), tp.extract(&language_server), "notify", tp.extract(&method), tp.extract_cbor(¶ms_cb) })) {
|
||||
|
|
|
@ -200,6 +200,10 @@ fn process_project_manager(self: *Self, m: tp.message) MessageFilter.Error!void
|
|||
self.need_reset = true;
|
||||
if (!std.mem.eql(u8, self.inputbox.text.items, query))
|
||||
try self.start_query();
|
||||
} else if (try cbor.match(m.buf, .{ "PRJ", "open_done", tp.string, tp.extract(&self.longest), tp.any })) {
|
||||
self.query_pending = false;
|
||||
self.need_reset = true;
|
||||
try self.start_query();
|
||||
} else {
|
||||
self.logger.err("receive", tp.unexpected(m));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue