feat: show file type icon in open_file completion

This commit is contained in:
CJ van den Berg 2025-08-09 22:20:17 +02:00
parent b913b8ad87
commit ab0a8f3c2c
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 83 additions and 40 deletions

View file

@ -793,12 +793,19 @@ fn request_path_files_async(a_: std.mem.Allocator, parent_: tp.pid_ref, project_
var iter = self.dir.iterateAssumeFirstIteration();
errdefer |e| self.parent.send(.{ "PRJ", "path_error", self.project_name, self.path, e }) catch {};
while (try iter.next()) |entry| {
switch (entry.kind) {
.directory => try self.parent.send(.{ "PRJ", "path_entry", self.project_name, self.path, "DIR", entry.name }),
.sym_link => try self.parent.send(.{ "PRJ", "path_entry", self.project_name, self.path, "LINK", entry.name }),
.file => try self.parent.send(.{ "PRJ", "path_entry", self.project_name, self.path, "FILE", entry.name }),
const event_type = switch (entry.kind) {
.directory => "DIR",
.sym_link => "LINK",
.file => "FILE",
else => continue,
}
};
const default = file_type_config.default;
const file_type, const icon, const color = switch (entry.kind) {
.directory => .{ "directory", file_type_config.folder_icon, default.color },
.sym_link, .file => Project.guess_path_file_type(self.path, entry.name),
else => .{ default.name, default.icon, default.color },
};
try self.parent.send(.{ "PRJ", "path_entry", self.project_name, self.path, event_type, entry.name, file_type, icon, color });
count += 1;
if (count >= self.max) break;
}