summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-08-21 20:53:21 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-08-21 23:05:52 -0400
commit74a89be64110a61972169c4a7f0e44ea2a43b4ec (patch)
treeb7f58377c7df6770c98f918fe774d43442a74e9a
parent5b1ce8bdc2391df82f2e9b4d8cc7b64f46c6c9a2 (diff)
grep-printer: fix bug in printing truncated lines
When emitting color, the printer wasn't checking whether the line exceeded the maximum allowed length.
-rw-r--r--grep-printer/src/standard.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/grep-printer/src/standard.rs b/grep-printer/src/standard.rs
index 6146a8b9..183fa4b5 100644
--- a/grep-printer/src/standard.rs
+++ b/grep-printer/src/standard.rs
@@ -1201,6 +1201,9 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
if !self.wtr().borrow().supports_color() || spec.is_none() {
return self.write_line(line);
}
+ if self.exceeds_max_columns(line) {
+ return self.write_exceeded_line();
+ }
let mut last_written =
if !self.config().trim_ascii {