Enforce 79 column limit. Grr.

This commit is contained in:
Andrew Gallant
2017-03-31 15:59:04 -04:00
parent 1425d6735e
commit fc975af8e9
5 changed files with 15 additions and 14 deletions

View File

@@ -153,9 +153,6 @@ impl<W: WriteColor> Printer<W> {
/// Replace every match in each matching line with the replacement string
/// given.
///
/// The replacement string syntax is documented here:
/// https://doc.rust-lang.org/regex/regex/bytes/struct.Captures.html#method.expand
pub fn replace(mut self, replacement: Vec<u8>) -> Printer<W> {
self.replace = Some(replacement);
self
@@ -290,7 +287,8 @@ impl<W: WriteColor> Printer<W> {
re.replace_all(&buf[start..end], replacer)
};
if self.max_columns.map_or(false, |m| line.len() > m) {
let msg = format!("[Omitted long line with {} replacements]", count);
let msg = format!(
"[Omitted long line with {} replacements]", count);
self.write_colored(msg.as_bytes(), |colors| colors.matched());
self.write_eol();
return;
@@ -319,7 +317,8 @@ impl<W: WriteColor> Printer<W> {
let mut last_written = 0;
for m in re.find_iter(buf) {
self.write(&buf[last_written..m.start()]);
self.write_colored(&buf[m.start()..m.end()], |colors| colors.matched());
self.write_colored(
&buf[m.start()..m.end()], |colors| colors.matched());
last_written = m.end();
}
self.write(&buf[last_written..]);