mirror of https://github.com/zkat/miette.git
Merge 829c4445a1 into b466948965
This commit is contained in:
commit
4e43abaacd
|
|
@ -1,6 +1,8 @@
|
|||
use std::fmt::{self, Write};
|
||||
|
||||
use owo_colors::{OwoColorize, Style, StyledList};
|
||||
use textwrap::WordSeparator;
|
||||
use textwrap::WordSplitter;
|
||||
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
|
||||
|
||||
use crate::diagnostic_chain::{DiagnosticChain, ErrorKind};
|
||||
|
|
@ -61,7 +63,7 @@ impl GraphicalReportHandler {
|
|||
tab_width: 4,
|
||||
with_cause_chain: true,
|
||||
wrap_lines: true,
|
||||
break_words: true,
|
||||
break_words: false,
|
||||
with_primary_span_start: true,
|
||||
word_separator: None,
|
||||
word_splitter: None,
|
||||
|
|
@ -83,7 +85,7 @@ impl GraphicalReportHandler {
|
|||
wrap_lines: true,
|
||||
with_cause_chain: true,
|
||||
with_primary_span_start: true,
|
||||
break_words: true,
|
||||
break_words: false,
|
||||
word_separator: None,
|
||||
word_splitter: None,
|
||||
highlighter: MietteHighlighter::default(),
|
||||
|
|
@ -262,16 +264,16 @@ impl GraphicalReportHandler {
|
|||
if let Some(footer) = &self.footer {
|
||||
writeln!(f)?;
|
||||
let width = self.termwidth.saturating_sub(2);
|
||||
let mut opts = textwrap::Options::new(width)
|
||||
let opts = textwrap::Options::new(width)
|
||||
.initial_indent(" ")
|
||||
.subsequent_indent(" ")
|
||||
.break_words(self.break_words);
|
||||
if let Some(word_separator) = self.word_separator {
|
||||
opts = opts.word_separator(word_separator);
|
||||
}
|
||||
if let Some(word_splitter) = self.word_splitter.clone() {
|
||||
opts = opts.word_splitter(word_splitter);
|
||||
}
|
||||
.break_words(self.break_words)
|
||||
.word_separator(self.word_separator.unwrap_or(WordSeparator::AsciiSpace))
|
||||
.word_splitter(
|
||||
self.word_splitter
|
||||
.clone()
|
||||
.unwrap_or(WordSplitter::NoHyphenation),
|
||||
);
|
||||
|
||||
writeln!(f, "{}", self.wrap(footer, opts))?;
|
||||
}
|
||||
|
|
@ -340,16 +342,16 @@ impl GraphicalReportHandler {
|
|||
let initial_indent = format!(" {} ", severity_icon.style(severity_style));
|
||||
let rest_indent = format!(" {} ", self.theme.characters.vbar.style(severity_style));
|
||||
let width = self.termwidth.saturating_sub(2);
|
||||
let mut opts = textwrap::Options::new(width)
|
||||
let opts = textwrap::Options::new(width)
|
||||
.initial_indent(&initial_indent)
|
||||
.subsequent_indent(&rest_indent)
|
||||
.break_words(self.break_words);
|
||||
if let Some(word_separator) = self.word_separator {
|
||||
opts = opts.word_separator(word_separator);
|
||||
}
|
||||
if let Some(word_splitter) = self.word_splitter.clone() {
|
||||
opts = opts.word_splitter(word_splitter);
|
||||
}
|
||||
.break_words(self.break_words)
|
||||
.word_separator(self.word_separator.unwrap_or(WordSeparator::AsciiSpace))
|
||||
.word_splitter(
|
||||
self.word_splitter
|
||||
.clone()
|
||||
.unwrap_or(WordSplitter::NoHyphenation),
|
||||
);
|
||||
|
||||
writeln!(f, "{}", self.wrap(&diagnostic.to_string(), opts))?;
|
||||
|
||||
|
|
@ -386,16 +388,16 @@ impl GraphicalReportHandler {
|
|||
)
|
||||
.style(severity_style)
|
||||
.to_string();
|
||||
let mut opts = textwrap::Options::new(width)
|
||||
let opts = textwrap::Options::new(width)
|
||||
.initial_indent(&initial_indent)
|
||||
.subsequent_indent(&rest_indent)
|
||||
.break_words(self.break_words);
|
||||
if let Some(word_separator) = self.word_separator {
|
||||
opts = opts.word_separator(word_separator);
|
||||
}
|
||||
if let Some(word_splitter) = self.word_splitter.clone() {
|
||||
opts = opts.word_splitter(word_splitter);
|
||||
}
|
||||
.break_words(self.break_words)
|
||||
.word_separator(self.word_separator.unwrap_or(WordSeparator::AsciiSpace))
|
||||
.word_splitter(
|
||||
self.word_splitter
|
||||
.clone()
|
||||
.unwrap_or(WordSplitter::NoHyphenation),
|
||||
);
|
||||
|
||||
match error {
|
||||
ErrorKind::Diagnostic(diag) => {
|
||||
|
|
@ -428,17 +430,16 @@ impl GraphicalReportHandler {
|
|||
if let Some(help) = diagnostic.help() {
|
||||
let width = self.termwidth.saturating_sub(2);
|
||||
let initial_indent = " help: ".style(self.theme.styles.help).to_string();
|
||||
let mut opts = textwrap::Options::new(width)
|
||||
let opts = textwrap::Options::new(width)
|
||||
.initial_indent(&initial_indent)
|
||||
.subsequent_indent(" ")
|
||||
.break_words(self.break_words);
|
||||
if let Some(word_separator) = self.word_separator {
|
||||
opts = opts.word_separator(word_separator);
|
||||
}
|
||||
if let Some(word_splitter) = self.word_splitter.clone() {
|
||||
opts = opts.word_splitter(word_splitter);
|
||||
}
|
||||
|
||||
.break_words(self.break_words)
|
||||
.word_separator(self.word_separator.unwrap_or(WordSeparator::AsciiSpace))
|
||||
.word_splitter(
|
||||
self.word_splitter
|
||||
.clone()
|
||||
.unwrap_or(WordSplitter::NoHyphenation),
|
||||
);
|
||||
writeln!(f, "{}", self.wrap(&help.to_string(), opts))?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -489,16 +490,16 @@ impl GraphicalReportHandler {
|
|||
.style(severity_style)
|
||||
.to_string();
|
||||
|
||||
let mut opts = textwrap::Options::new(width)
|
||||
let opts = textwrap::Options::new(width)
|
||||
.initial_indent(&initial_indent)
|
||||
.subsequent_indent(&rest_indent)
|
||||
.break_words(self.break_words);
|
||||
if let Some(word_separator) = self.word_separator {
|
||||
opts = opts.word_separator(word_separator);
|
||||
}
|
||||
if let Some(word_splitter) = self.word_splitter.clone() {
|
||||
opts = opts.word_splitter(word_splitter);
|
||||
}
|
||||
.break_words(self.break_words)
|
||||
.word_separator(self.word_separator.unwrap_or(WordSeparator::AsciiSpace))
|
||||
.word_splitter(
|
||||
self.word_splitter
|
||||
.clone()
|
||||
.unwrap_or(WordSplitter::NoHyphenation),
|
||||
);
|
||||
|
||||
let mut inner = String::new();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue