1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-14 01:02:25 +01:00

Simplify access to first line

This commit is contained in:
sharkdp
2018-10-07 13:47:54 +02:00
committed by David Peter
parent 1dbb4ef683
commit f98fc5f06a
2 changed files with 10 additions and 18 deletions

View File

@@ -180,10 +180,8 @@ impl HighlightingAssets {
.find_syntax_by_extension(file_name)
.or_else(|| self.syntax_set.find_syntax_by_extension(extension));
let line_syntax = if ext_syntax.is_none() {
reader
.get_first_line()
String::from_utf8(reader.first_line.clone())
.ok()
.and_then(|v| String::from_utf8(v).ok())
.and_then(|l| self.syntax_set.find_syntax_by_first_line(&l))
} else {
None