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

Skip syntax highlighting for long lines (#2165)

* Skip highlighting for long lines

* Run cargo fmt, update changelog
This commit is contained in:
Keith Hall
2022-05-04 08:59:24 +03:00
committed by GitHub
parent 5114c0189d
commit b5294f1cb2
4 changed files with 33 additions and 3 deletions

View File

@@ -445,9 +445,18 @@ impl<'a> Printer for InteractivePrinter<'a> {
return Ok(());
}
};
highlighter_from_set
.highlighter
.highlight(&line, highlighter_from_set.syntax_set)
// skip syntax highlighting on long lines
if line.len() > 1024 * 16 {
let mut empty = highlighter_from_set
.highlighter
.highlight(&"\n", highlighter_from_set.syntax_set);
empty[0].1 = line.as_ref();
empty
} else {
highlighter_from_set
.highlighter
.highlight(&line, highlighter_from_set.syntax_set)
}
};
if out_of_range {