Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix too many anonymized line numbers #5

Merged
merged 1 commit into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the case of DisplaySourceLine::Empty + Some(lineno) also be handled in some way? I didn't see any test cases for it, so I left that out for now.

},
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