From ffcad71bfabefb82daa02592e2c3658bfdcca3b9 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Fri, 7 Feb 2025 00:14:39 +0100 Subject: [PATCH] file_icons: Resolve icon properly for exact file name match (#24396) Follow-up to #24391 The current approach has two issues: - For the described case of `eslint.config.js`, for which a mapping exists in `suffixes`, this would get mapped from `eslint.config.js` to `eslint`. However, for `eslint`, there is no mapping within `suffixes`, thus currently `get_icon_from_suffix` would return `None` and a wrong item would be returned at a later step. - Paths passed to this method are relative to the worktree root, thus e.g. `eslint.config.js` files in subdirectories would still be assigned the wrong icon. --- Behaviour on `main`: main Behaviour with this change: pr CC @probably-neb Release Notes: - N/A --- crates/file_icons/src/file_icons.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/file_icons/src/file_icons.rs b/crates/file_icons/src/file_icons.rs index 88b2003635..37b0a6b225 100644 --- a/crates/file_icons/src/file_icons.rs +++ b/crates/file_icons/src/file_icons.rs @@ -54,7 +54,7 @@ impl FileIcons { // 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.to_str().and_then(|typ| this.suffixes.get(typ)) { + if let Some(typ) = path.file_name().and_then(|typ| typ.to_str()) { let maybe_path = get_icon_from_suffix(typ); if maybe_path.is_some() { return maybe_path;