review comments

This commit is contained in:
Esteban Küber 2024-08-08 14:43:27 +00:00
parent ae696f847d
commit 95c1c34fff
5 changed files with 12 additions and 6 deletions

View file

@ -48,6 +48,12 @@ pub enum HumanReadableErrorType {
Short,
}
impl HumanReadableErrorType {
pub fn short(&self) -> bool {
*self == HumanReadableErrorType::Short
}
}
#[derive(Clone, Copy, Debug)]
struct Margin {
/// The available whitespace in the left that can be consumed when centering.

View file

@ -176,7 +176,7 @@ impl Emitter for JsonEmitter {
}
fn should_show_explain(&self) -> bool {
!matches!(self.json_rendered, HumanReadableErrorType::Short)
!self.json_rendered.short()
}
}
@ -356,7 +356,7 @@ impl Diagnostic {
let buf = BufWriter::default();
let mut dst: Destination = Box::new(buf.clone());
let short = matches!(je.json_rendered, HumanReadableErrorType::Short);
let short = je.json_rendered.short();
match je.color_config {
ColorConfig::Always | ColorConfig::Auto => dst = Box::new(termcolor::Ansi::new(dst)),
ColorConfig::Never => {}