mirror of
https://github.com/sharkdp/bat.git
synced 2024-10-31 20:11:01 +01:00
Skip syntax highlighting for long lines (#2165)
* Skip highlighting for long lines * Run cargo fmt, update changelog
This commit is contained in:
parent
5114c0189d
commit
b5294f1cb2
@ -12,6 +12,7 @@
|
|||||||
## Other
|
## Other
|
||||||
|
|
||||||
- Include info about custom assets in `--diagnostics` if used. See #2107, #2144 (@Enselic)
|
- 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
|
## Syntaxes
|
||||||
|
|
||||||
|
@ -445,9 +445,18 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
highlighter_from_set
|
// skip syntax highlighting on long lines
|
||||||
.highlighter
|
if line.len() > 1024 * 16 {
|
||||||
.highlight(&line, highlighter_from_set.syntax_set)
|
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 {
|
if out_of_range {
|
||||||
|
3
tests/examples/longline.json
vendored
Normal file
3
tests/examples/longline.json
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user