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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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)
@@ -515,13 +515,26 @@ fn test_anon_lines() {
range: (0, 19),
},
},
DisplayLine::Source {
lineno: None,
inline_marks: vec![],
line: DisplaySourceLine::Empty,

This comment has been minimized.

@phansch

phansch Jul 15, 2019
Author Member

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"
);
}