Use first-line detection for STDIN

This commit is contained in:
sharkdp 2018-10-07 14:31:23 +02:00 committed by David Peter
parent ce96df00b6
commit e97095b724

View File

@ -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"),
};