pub fn format(&self) -> String {
        if self.lines.is_empty() {
            return String::new();
        }

        // First check if we have any valid grep format entries
        let has_valid_entries = self
            .lines
            .iter()
            .any(|line| ParsedLine::parse(line).is_some());

        // If no valid grep format entries found, treat all lines as raw file paths
        if !has_valid_entries {
            return self.format_raw_paths();
        }

        // First pass: collect entries and find max width
        let (entries, max_num_width) = self.collect_entries();

        // Print the results on separate lines
        let formatted_entries: Vec<_> = entries
            .into_iter()
            .map(|(path, group)| self.format_file_group(path, group, max_num_width))
            .collect();

        // Join all results with newlines
        formatted_entries.join("\n")
    }
Format search results with colorized output grouped by path
crates/forge_display/src/grep.rs