diff --git a/src/assets.rs b/src/assets.rs
index d731fc3f..544acaf2 100644
--- a/src/assets.rs
+++ b/src/assets.rs
@@ -220,12 +220,7 @@ impl HighlightingAssets {
let file_name = file_name.as_ref();
Ok(match mapping.get_syntax_for(file_name) {
Some(MappingTarget::MapToUnknown) => None,
- Some(MappingTarget::MapTo(syntax_name)) => {
- let syntax_set = self.get_syntax_set()?;
- syntax_set
- .find_syntax_by_name(syntax_name)
- .map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })
- }
+ Some(MappingTarget::MapTo(syntax_name)) => self.find_syntax_by_name(syntax_name)?,
None => self.get_extension_syntax(file_name.as_os_str())?,
})
}
@@ -287,13 +282,9 @@ impl HighlightingAssets {
Some(MappingTarget::MapToUnknown) => line_syntax
.ok_or_else(|| Error::UndetectedSyntax(path.to_string_lossy().into())),
- Some(MappingTarget::MapTo(syntax_name)) => {
- let syntax_set = self.get_syntax_set()?;
- syntax_set
- .find_syntax_by_name(syntax_name)
- .map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })
- .ok_or_else(|| Error::UnknownSyntax(syntax_name.to_owned()))
- }
+ Some(MappingTarget::MapTo(syntax_name)) => self
+ .find_syntax_by_name(syntax_name)?
+ .ok_or_else(|| Error::UnknownSyntax(syntax_name.to_owned())),
None => {
let file_name = path.file_name().unwrap_or_default();
@@ -308,6 +299,13 @@ impl HighlightingAssets {
}
}
+ fn find_syntax_by_name(&self, syntax_name: &str) -> Result