diff options
author | sharkdp <davidpeter@web.de> | 2018-10-07 14:31:23 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2018-10-07 15:34:37 +0200 |
commit | e97095b724b763e6841c08d9b89b20089592d310 (patch) | |
tree | fe379107d8880770582fe7992df95c3f847f9bf9 /src/assets.rs | |
parent | ce96df00b6e77841f7c77fdc50e5b6e5b944e375 (diff) |
Use first-line detection for STDIN
Diffstat (limited to 'src/assets.rs')
-rw-r--r-- | src/assets.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/assets.rs b/src/assets.rs index 4bf8f6a3..b8655dbb 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -189,7 +189,9 @@ impl HighlightingAssets { let syntax = ext_syntax.or(line_syntax); syntax } - (None, InputFile::StdIn) => None, + (None, InputFile::StdIn) => String::from_utf8(reader.first_line.clone()) + .ok() + .and_then(|l| self.syntax_set.find_syntax_by_first_line(&l)), (_, InputFile::ThemePreviewFile) => self.syntax_set.find_syntax_by_name("Rust"), }; |