Skip to content

Commit

Permalink
Fix incorrect assumption about Path.extension() (#24443)
Browse files Browse the repository at this point in the history
Release Notes:

- N/A
  • Loading branch information
probably-neb authored Feb 7, 2025
1 parent 4f65cfa commit a1544f4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/language/src/language_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ impl LanguageRegistry {
user_file_types: Option<&HashMap<Arc<str>, GlobSet>>,
) -> Option<AvailableLanguage> {
let filename = path.file_name().and_then(|name| name.to_str());
let extension = path.extension().and_then(|ext| ext.to_str());
// `Path.extension()` returns None for files with a leading '.'
// and no other extension which is not the desired behavior here,
// as we want `.zshrc` to result in extension being `Some("zshrc")`
let extension = filename.and_then(|filename| filename.split('.').last());
let path_suffixes = [extension, filename, path.to_str()];
let empty = GlobSet::empty();

Expand Down

0 comments on commit a1544f4

Please sign in to comment.