mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
Only emit bold ANSI code if bold is true.
This was a simple logic error. Also, avoid emitting ANSI escape codes if there are no color settings. Fixes #242
This commit is contained in:
parent
a5e7f176f1
commit
ae592b11e3
@ -260,7 +260,7 @@ impl<W: WriteColor> Printer<W> {
|
||||
}
|
||||
|
||||
fn write_matched_line(&mut self, re: &Regex, buf: &[u8]) {
|
||||
if !self.wtr.supports_color() {
|
||||
if !self.wtr.supports_color() || self.colors.matched().is_none() {
|
||||
self.write(buf);
|
||||
return;
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ impl<W: io::Write> WriteColor for Ansi<W> {
|
||||
if let Some(ref c) = spec.bg_color {
|
||||
try!(self.write_color(false, c, spec.bold));
|
||||
}
|
||||
if spec.fg_color.is_none() && spec.bg_color.is_none() {
|
||||
if spec.bold && spec.fg_color.is_none() && spec.bg_color.is_none() {
|
||||
try!(self.write_str("\x1B[1m"));
|
||||
}
|
||||
Ok(())
|
||||
@ -969,6 +969,11 @@ impl ColorSpec {
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns true if this color specification has no colors or styles.
|
||||
pub fn is_none(&self) -> bool {
|
||||
self.fg_color.is_none() && self.bg_color.is_none() && !self.bold
|
||||
}
|
||||
|
||||
/// Clears this color specification so that it has no color/style settings.
|
||||
pub fn clear(&mut self) {
|
||||
self.fg_color = None;
|
||||
|
Loading…
Reference in New Issue
Block a user