mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 15:42:23 -05:00
fix(report): Align text when tabs are used
Ideally we would provide for more than a space per tab but this at least gets us better alignment. Fixes #11
This commit is contained in:
parent
a082207283
commit
80aeed1b43
1 changed files with 4 additions and 7 deletions
|
@ -35,6 +35,9 @@ pub fn print_long(msg: Message) {
|
|||
let hl_indent: String = itertools::repeat_n(" ", msg.col_num).collect();
|
||||
let hl: String = itertools::repeat_n("^", msg.word.len()).collect();
|
||||
|
||||
let line = String::from_utf8_lossy(msg.line);
|
||||
let line = line.replace("\t", " ");
|
||||
|
||||
let stdout = io::stdout();
|
||||
let mut handle = stdout.lock();
|
||||
|
||||
|
@ -53,13 +56,7 @@ pub fn print_long(msg: Message) {
|
|||
)
|
||||
.unwrap();
|
||||
writeln!(handle, "{} |", line_indent).unwrap();
|
||||
writeln!(
|
||||
handle,
|
||||
"{} | {}",
|
||||
msg.line_num,
|
||||
String::from_utf8_lossy(msg.line).trim_end()
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(handle, "{} | {}", msg.line_num, line.trim_end()).unwrap();
|
||||
writeln!(handle, "{} | {}{}", line_indent, hl_indent, hl).unwrap();
|
||||
writeln!(handle, "{} |", line_indent).unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue