Skip to content

Print entire comment line for report_todo/report_fixme #3912

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

Merged
merged 1 commit into from
Nov 14, 2019
Merged
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
11 changes: 10 additions & 1 deletion src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ impl<'a> FormatLines<'a> {

// Iterate over the chars in the file map.
fn iterate(&mut self, text: &mut String) {
// List of TODO or FIXME issues on the current line
let mut issues_on_line = Vec::new();

for (kind, c) in CharClasses::new(text.chars()) {
if c == '\r' {
continue;
Expand All @@ -499,11 +502,17 @@ impl<'a> FormatLines<'a> {
if self.allow_issue_seek && self.format_line {
// Add warnings for bad todos/ fixmes
if let Some(issue) = self.issue_seeker.inspect(c) {
self.push_err(ErrorKind::BadIssue(issue), false, false);
issues_on_line.push(issue);
}
}

if c == '\n' {
// Accumulate TODO or FIXME issues for the rest of the line so the resulting error
// messages contain the entire comment line
for issue in issues_on_line.drain(..) {
self.push_err(ErrorKind::BadIssue(issue), false, false);
}

self.new_line(kind);
} else {
self.char(c, kind);
Expand Down