Fix incorrect assumption about Path.extension()
(#24443)
Release Notes: - N/A
This commit is contained in:
parent
4f65cfa93d
commit
a1544f47ad
1 changed files with 4 additions and 1 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue