Repository: lapce/lapce
File: lapce-ui/src/svg.rs (Rust)

Code before:

            let (mut icon, mut color) = (None, None);

            for (exts, file_type, col) in TYPES {
                for ext in exts.iter() {
                    if extension.eq_ignore_ascii_case(ext) {
                        (icon, color) = (Some(*file_type), *col)
                    }
                }
            }

            (icon, color)
        }
        None => match path.file_name().and_then(OsStr::to_str) {
            Some(file_name) => {
                const FILES: &[(&[&str], &str, Option<&Color>)] = &[
                    (&["LICENSE", "LICENCE"], "file_type_license.svg", None),
                    (&["COPYRIGHT"], "file_type_license.svg", None),
                    (&["NOTICE"], "file_type_license.svg", None),
                ];

                let (mut icon, mut color) = (None, None);

                for (filenames, file_type, col) in FILES {
                    for filename in filenames.iter() {
                        if file_name.starts_with(filename) {
                            (icon, color) = (Some(*file_type), *col)
                        }
                    }
                }

                (icon, color)
            }
            None => (Some("default_file.svg"), None),
        },
    };

    match icon_name {
        Some(icon_name) => match get_svg(icon_name) {
            Some(svg) => (svg, icon_color),
            None => (get_svg("default_file.svg").unwrap(), None),
        },
        None => (get_svg("default_file.svg").unwrap(), None),
    }
}

pub fn symbol_svg(kind: &SymbolKind) -> Option<Svg> {
    let kind_str = match *kind {
        SymbolKind::ARRAY => "symbol-array.svg",
        SymbolKind::BOOLEAN => "symbol-boolean.svg",
        SymbolKind::CLASS => "symbol-class.svg",

Review comment (suggestion):
should be
```suggestion
                        if file_name.to_lowercase().starts_with(filename) {
```

Code after:
                }
            }

            (icon, color)
        }
        None => match path.file_name().and_then(OsStr::to_str) {
            Some(file_name) => {
                const FILES: &[(&[&str], &str, Option<&Color>)] = &[
                    (&["LICENSE", "LICENCE"], "file_type_license.svg", None),
                    (&["COPYRIGHT"], "file_type_license.svg", None),
                    (&["NOTICE"], "file_type_license.svg", None),
                ];

                let (mut icon, mut color) = (None, None);

                for (filenames, file_type, col) in FILES {
                    for filename in filenames.iter() {
                        if file_name.to_lowercase().starts_with(filename) {
                            (icon, color) = (Some(*file_type), *col)
                        }
                    }
                }

                (icon, color)
            }
            None => (Some("default_file.svg"), None),
        },
    };

    match icon_name {
        Some(icon_name) => match get_svg(icon_name) {
            Some(svg) => (svg, icon_color),
            None => (get_svg("default_file.svg").unwrap(), None),
        },
        None => (get_svg("default_file.svg").unwrap(), None),
    }
}

pub fn symbol_svg(kind: &SymbolKind) -> Option<Svg> {
    let kind_str = match *kind {
        SymbolKind::ARRAY => "symbol-array.svg",
        SymbolKind::BOOLEAN => "symbol-boolean.svg",
        SymbolKind::CLASS => "symbol-class.svg",
        SymbolKind::CONSTANT => "symbol-constant.svg",
        SymbolKind::ENUM_MEMBER => "symbol-enum-member.svg",
        SymbolKind::ENUM => "symbol-enum.svg",
        SymbolKind::EVENT => "symbol-event.svg",
        SymbolKind::FIELD => "symbol-field.svg",
        SymbolKind::FILE => "symbol-file.svg",
        SymbolKind::INTERFACE => "symbol-interface.svg",
        SymbolKind::KEY => "symbol-key.svg",