Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Enhance icon detection for files with custom suffixes (#34170)
Gilmar Sales6c1f19571a56
diff --git a/crates/file_icons/src/file_icons.rs b/crates/file_icons/src/file_icons.rsindex 2f159771b1a..82a8e05d857 100644--- a/crates/file_icons/src/file_icons.rs+++ b/crates/file_icons/src/file_icons.rs@@ -33,13 +33,23 @@ impl FileIcons {// TODO: Associate a type with the languages and have the file's language// override these associations- // check if file name is in suffixes- // e.g. catch file named `eslint.config.js` instead of `.eslint.config.js`- if let Some(typ) = path.file_name().and_then(|typ| typ.to_str()) {+ if let Some(mut typ) = path.file_name().and_then(|typ| typ.to_str()) {+ // check if file name is in suffixes+ // e.g. catch file named `eslint.config.js` instead of `.eslint.config.js`let maybe_path = get_icon_from_suffix(typ);if maybe_path.is_some() {return maybe_path;}++ // check if suffix based on first dot is in suffixes+ // e.g. consider `module.js` as suffix to angular's module file named `auth.module.js`+ while let Some((_, suffix)) = typ.split_once('.') {+ let maybe_path = get_icon_from_suffix(suffix);+ if maybe_path.is_some() {+ return maybe_path;+ }+ typ = suffix;+ }}// primary case: check if the files extension or the hidden file name