Skip to content

Commit

Permalink
fix(report): Align text when tabs are used
Browse files Browse the repository at this point in the history
Ideally we would provide for more than a space per tab but this at least
gets us better alignment.

Fixes #11
  • Loading branch information
epage committed Jun 22, 2019
1 parent a082207 commit 80aeed1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
}
Expand Down

0 comments on commit 80aeed1

Please sign in to comment.