HighlightingAssets: Inline absolute_path

Its name is confusing, because it does not always hold an absolute path. Get rid
of this problem by inlining it.
This commit is contained in:
Martin Nordholts 2021-09-16 17:02:18 +02:00
parent 82f439e715
commit d989224a8a
1 changed files with 3 additions and 4 deletions

View File

@ -212,10 +212,9 @@ impl HighlightingAssets {
let path_syntax = if let Some(path) = path {
// If a path was provided, we try and detect the syntax based on extension mappings.
let absolute_path =
PathAbs::new(path).map_or_else(|_| path.to_owned(), |p| p.as_path().to_path_buf());
match mapping.get_syntax_for(absolute_path) {
match mapping.get_syntax_for(
PathAbs::new(path).map_or_else(|_| path.to_owned(), |p| p.as_path().to_path_buf()),
) {
Some(MappingTarget::MapToUnknown) => {
Err(Error::UndetectedSyntax(path.to_string_lossy().into()))
}