Fix incorrect assumption about Path.extension() (#24443)
Release Notes: - N/A
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user