feat(loader): support multi-barreled file extensions

This commit is contained in:
WillLillis 2024-11-02 23:43:34 -04:00 committed by Amaan Qureshi
parent 7b90dbf189
commit 05b6871a02
2 changed files with 123 additions and 5 deletions

View file

@ -522,11 +522,15 @@ impl Loader {
.and_then(|n| n.to_str())
.and_then(|file_name| self.language_configuration_ids_by_file_type.get(file_name))
.or_else(|| {
path.extension()
.and_then(|extension| extension.to_str())
.and_then(|extension| {
self.language_configuration_ids_by_file_type.get(extension)
})
let mut path = path.to_owned();
let mut extensions = Vec::with_capacity(2);
while let Some(extension) = path.extension() {
extensions.push(extension.to_str()?.to_string());
path = PathBuf::from(path.file_stem()?.to_os_string());
}
extensions.reverse();
self.language_configuration_ids_by_file_type
.get(&extensions.join("."))
});
if let Some(configuration_ids) = configuration_ids {