|
44 | 44 | //! **Implementation**: |
45 | 45 | //! 1. Calls `comments_before(node.span.start)` to get unprinted leading comments |
46 | 46 | //! 2. Formats each comment with spacing based on line breaks in original source |
47 | | -//! 3. Advances cursor by calling `increment_printed_count()` for each comment |
| 47 | +//! 3. Advances cursor by calling `increment_printed_count(comment)` for each comment |
48 | 48 | //! 4. Handles special cases like JSDoc comment "nestling" |
49 | 49 | //! |
50 | 50 | //! ### Trailing Comment Formatting ([`FormatTrailingComments`]) |
@@ -149,7 +149,7 @@ impl<'a> Format<'a, JsFormatContext<'a>> for FormatLeadingComments<'a> { |
149 | 149 | ) { |
150 | 150 | let mut leading_comments_iter = comments.into_iter().peekable(); |
151 | 151 | while let Some(comment) = leading_comments_iter.next() { |
152 | | - f.context_mut().comments_mut().increment_printed_count(); |
| 152 | + f.context_mut().comments_mut().increment_printed_count(comment); |
153 | 153 | write!(f, format_comment_text(comment)); |
154 | 154 |
|
155 | 155 | let lines_after = f |
@@ -265,7 +265,7 @@ impl<'a> Format<'a, JsFormatContext<'a>> for FormatTrailingComments<'a> { |
265 | 265 | let mut previous_comment: Option<&Comment> = None; |
266 | 266 |
|
267 | 267 | for comment in comments { |
268 | | - f.context_mut().comments_mut().increment_printed_count(); |
| 268 | + f.context_mut().comments_mut().increment_printed_count(comment); |
269 | 269 |
|
270 | 270 | let lines_before = f.lines_before(comment.span); |
271 | 271 | total_lines_before += lines_before; |
@@ -447,7 +447,7 @@ impl<'a> Format<'a, JsFormatContext<'a>> for FormatDanglingComments<'a> { |
447 | 447 | let mut previous_comment: Option<&Comment> = None; |
448 | 448 |
|
449 | 449 | for comment in comments { |
450 | | - f.context_mut().comments_mut().increment_printed_count(); |
| 450 | + f.context_mut().comments_mut().increment_printed_count(comment); |
451 | 451 |
|
452 | 452 | let should_nestle = previous_comment.is_some_and(|previous_comment| { |
453 | 453 | should_nestle_adjacent_comments(previous_comment, comment, f.source_text()) |
@@ -603,7 +603,7 @@ impl<'a> FormatCommentBeforeContent<'a> { |
603 | 603 |
|
604 | 604 | impl<'a> Format<'a, JsFormatContext<'a>> for FormatCommentBeforeContent<'_> { |
605 | 605 | fn fmt(&self, f: &mut JsFormatter<'_, 'a>) { |
606 | | - f.context_mut().comments_mut().increment_printed_count(); |
| 606 | + f.context_mut().comments_mut().increment_printed_count(self.0); |
607 | 607 | write!(f, format_comment_text(self.0)); |
608 | 608 | if self.0.is_line() { |
609 | 609 | write!(f, hard_line_break()); |
|
0 commit comments