Skip to content

Commit 3773466

Browse files
tangmitopecongiro
authored andcommitted
Print entire comment line for report_todo/report_fixme (#3912)
1 parent 7ecd467 commit 3773466

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/formatting.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ impl<'a> FormatLines<'a> {
507507

508508
// Iterate over the chars in the file map.
509509
fn iterate(&mut self, text: &mut String) {
510+
// List of TODO or FIXME issues on the current line
511+
let mut issues_on_line = Vec::new();
512+
510513
for (kind, c) in CharClasses::new(text.chars()) {
511514
if c == '\r' {
512515
continue;
@@ -515,11 +518,17 @@ impl<'a> FormatLines<'a> {
515518
if self.allow_issue_seek && self.format_line {
516519
// Add warnings for bad todos/ fixmes
517520
if let Some(issue) = self.issue_seeker.inspect(c) {
518-
self.push_err(ErrorKind::BadIssue(issue), false, false);
521+
issues_on_line.push(issue);
519522
}
520523
}
521524

522525
if c == '\n' {
526+
// Accumulate TODO or FIXME issues for the rest of the line so the resulting error
527+
// messages contain the entire comment line
528+
for issue in issues_on_line.drain(..) {
529+
self.push_err(ErrorKind::BadIssue(issue), false, false);
530+
}
531+
523532
self.new_line(kind);
524533
} else {
525534
self.char(c, kind);

0 commit comments

Comments
 (0)