diff options
author | sharkdp <davidpeter@web.de> | 2020-04-21 22:24:47 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-04-22 23:55:28 +0200 |
commit | f3b90ddb383cfcbd575f24785a5a9400870d162e (patch) | |
tree | 9c81e6f1d1fa50b0e9df37d9c2a9a3c6a7feb150 /src/assets.rs | |
parent | 3bacfc5184184c4a845d56f9e7226e87eae6d172 (diff) |
Add InputDescription
Diffstat (limited to 'src/assets.rs')
-rw-r--r-- | src/assets.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/assets.rs b/src/assets.rs index 55bf3ef0..f6b10b3a 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -188,11 +188,11 @@ impl HighlightingAssets { pub(crate) fn get_syntax( &self, language: Option<&str>, - file: &Input, + input: &Input, reader: &mut InputReader, mapping: &SyntaxMapping, ) -> &SyntaxReference { - let syntax = match (language, file) { + let syntax = match (language, input) { (Some(language), _) => self.syntax_set.find_syntax_by_token(language), (None, Input::Ordinary(ofile)) => { let path = Path::new(ofile.provided_path()); @@ -282,12 +282,11 @@ mod tests { } let input = Input::Ordinary(OrdinaryFile::from_path(file_path.as_os_str())); - let syntax = self.assets.get_syntax( - None, - &input, - &mut input.get_reader(io::stdin().lock()).unwrap(), - &self.syntax_mapping, - ); + let stdin = io::stdin(); + let mut reader = input.get_reader(stdin.lock()).unwrap(); + let syntax = self + .assets + .get_syntax(None, &input, &mut reader, &self.syntax_mapping); syntax.name.clone() } |