Skip to content

Commit

Permalink
Merge pull request #5 from phansch/fix_too_many_linenumbers
Browse files Browse the repository at this point in the history
Fix too many anonymized line numbers
  • Loading branch information
zbraniecki authored Jul 15, 2019
2 parents e23e557 + b3b2032 commit 860899e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/formatter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl DisplayListFormatter {
inline_marks,
line,
} => {
let lineno = if self.anonymized_line_numbers {
let lineno = if self.anonymized_line_numbers && lineno.is_some() {
Self::ANONYMIZED_LINE_NUM.to_string()
} else {
self.format_lineno(*lineno, lineno_width)
Expand Down
15 changes: 14 additions & 1 deletion tests/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,26 @@ fn test_anon_lines() {
range: (0, 19),
},
},
DisplayLine::Source {
lineno: None,
inline_marks: vec![],
line: DisplaySourceLine::Empty,
},
DisplayLine::Source {
lineno: None,
inline_marks: vec![],
line: DisplaySourceLine::Content {
text: "abc".to_string(),
range: (0, 19),
},
},
]);

let dlf = DisplayListFormatter::new(false, true);

assert_eq!(
dlf.format(&dl),
"LL | This is an example\nLL | of content lines"
"LL | This is an example\nLL | of content lines\n |\n | abc"
);
}

Expand Down

0 comments on commit 860899e

Please sign in to comment.