on master help sign in
Use first-line detection for STDIN
commite97095b724b763e6841c08d9b89b20089592d310 authorsharkdp <davidpeter@web.de> dateSun 7 Oct 2018, 14:31 (8 years ago) parentce96df0
1 file changed+3−1
src/assets.rs+3−1
src/assets.rs+3−1
@@ -189,7 +189,9 @@ impl HighlightingAssets {
189189 let syntax = ext_syntax.or(line_syntax);
190190 syntax
191191 }
192− (None, InputFile::StdIn) => None,
192+ (None, InputFile::StdIn) => String::from_utf8(reader.first_line.clone())
193+ .ok()
194+ .and_then(|l| self.syntax_set.find_syntax_by_first_line(&l)),
193195 (_, InputFile::ThemePreviewFile) => self.syntax_set.find_syntax_by_name("Rust"),
194196 };
195197