diff options
author | Martin Nordholts <enselic@gmail.com> | 2021-09-26 10:00:40 +0200 |
---|---|---|
committer | Martin Nordholts <enselic@gmail.com> | 2021-09-27 08:00:58 +0200 |
commit | dc8225f6828e30a7acad09b0a9f9b3f1c30fc533 (patch) | |
tree | b476d7981a6f132435d7b3db296f7fdfc5c7912a /src/assets.rs | |
parent | 9d9b266f543c770d5f45098cab2a72c882ca4f48 (diff) |
src/assets.rs: Extract helper method OpenedInput::path()
Diffstat (limited to 'src/assets.rs')
-rw-r--r-- | src/assets.rs | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/assets.rs b/src/assets.rs index f9a990fe..55cad098 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -11,7 +11,7 @@ use path_abs::PathAbs; use crate::bat_warning; use crate::error::*; -use crate::input::{InputReader, OpenedInput, OpenedInputKind}; +use crate::input::{InputReader, OpenedInput}; use crate::syntax_mapping::{MappingTarget, SyntaxMapping}; use ignored_suffixes::*; @@ -198,18 +198,7 @@ impl HighlightingAssets { .ok_or_else(|| Error::UnknownSyntax(language.to_owned())); } - // Get the path of the file: - // If this was set by the metadata, that will take priority. - // If it wasn't, it will use the real file path (if available). - let path = input - .metadata - .user_provided_name - .as_ref() - .or_else(|| match input.kind { - OpenedInputKind::OrdinaryFile(ref path) => Some(path), - _ => None, - }); - + let path = input.path(); let path_syntax = if let Some(path) = path { // If a path was provided, we try and detect the syntax based on extension mappings. match mapping.get_syntax_for( |