From 74a89be64110a61972169c4a7f0e44ea2a43b4ec Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 21 Aug 2018 20:53:21 -0400 Subject: [PATCH] grep-printer: fix bug in printing truncated lines When emitting color, the printer wasn't checking whether the line exceeded the maximum allowed length. --- grep-printer/src/standard.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grep-printer/src/standard.rs b/grep-printer/src/standard.rs index 6146a8b..183fa4b 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 {