Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
faultyserver committed Dec 15, 2023
1 parent d40ea51 commit 88cab29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 6 additions & 0 deletions crates/biome_formatter/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,12 @@ pub fn is_alignable_comment<L: Language>(comment: &SyntaxTriviaPieceComments<L>)
})
}

/// **TODO:** This is really JS-specific logic, both in syntax and semantics.
/// It should probably be moved to `biome_js_formatter` when possible, but is
/// currently tied to other behavior about formatting sets of comments (which
/// might also be best to move as well, since it relates to the same specific
/// behavior).
///
/// Returns `true` if `comment` is a documentation-style comment, specifically
/// matching the JSDoc format where the comment:
/// - spans over multiple lines
Expand Down
11 changes: 5 additions & 6 deletions crates/biome_formatter/src/trivia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ where
FormatLeadingComments::Comments(comments) => comments,
};

for (index, comment) in leading_comments.iter().enumerate() {
let mut leading_comments_iter = leading_comments.iter().peekable();
while let Some(comment) = leading_comments_iter.next() {
let format_comment = FormatRefWithRule::new(comment, Context::CommentRule::default());
write!(f, [format_comment])?;

Expand All @@ -75,11 +76,9 @@ where
match comment.lines_after() {
0 => {
let should_nestle =
leading_comments
.get(index + 1)
.map_or(false, |next_comment| {
should_nestle_adjacent_doc_comments(comment, next_comment)
});
leading_comments_iter.peek().map_or(false, |next_comment| {
should_nestle_adjacent_doc_comments(comment, next_comment)
});

write!(f, [maybe_space(!should_nestle)])?;
}
Expand Down

0 comments on commit 88cab29

Please sign in to comment.