feat: show file type icon in open_file completion
This commit is contained in:
		
							parent
							
								
									b913b8ad87
								
							
						
					
					
						commit
						ab0a8f3c2c
					
				
					 4 changed files with 83 additions and 40 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue