1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-22 16:53:19 +00: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
+1
View File
@@ -12,6 +12,7 @@
## Other
- Include info about custom assets in `--diagnostics` if used. See #2107, #2144 (@Enselic)
- Skip syntax highlighting on long lines (> 16384 chars) to help improve performance. See #2165 (@keith-hall)
## Syntaxes
+12 -3
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 {
+3
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long