Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nbacquey committed Jan 9, 2025
1 parent 0e1d3a1 commit a2990d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 14 additions & 4 deletions topiary-core/src/atom_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,17 +959,22 @@ impl AtomCollection {
single_line_no_indent: false,
multi_line_indent_all: true,
};
comments_queue_with_context.push_front(CommentWithContext{
comments_queue_with_context.push_front(CommentWithContext {
comment: comment_atom,
blank_line_after,
blank_line_before
blank_line_before,
});
}
atoms_with_comments_before.push_front(atom);
} else if Atom::Hardline == atom || Atom::Blankline == atom {
let mut blank_line_before_first_comment = false;
// Prepend the comments, each one followed by a newline
while let Some(CommentWithContext{comment, blank_line_after, blank_line_before}) = comments_queue_with_context.pop_back() {
while let Some(CommentWithContext {
comment,
blank_line_after,
blank_line_before,
}) = comments_queue_with_context.pop_back()
{
if blank_line_after {
atoms_with_comments_before.push_front(Atom::Blankline)
} else {
Expand All @@ -989,7 +994,12 @@ impl AtomCollection {
}
let mut blank_line_before_first_comment = false;
// If we still have comments left, add them at the beginning of the file
while let Some(CommentWithContext{comment, blank_line_after, blank_line_before}) = comments_queue_with_context.pop_back() {
while let Some(CommentWithContext {
comment,
blank_line_after,
blank_line_before,
}) = comments_queue_with_context.pop_back()
{
if blank_line_after {
atoms_with_comments_before.push_front(Atom::Blankline)
} else {
Expand Down
6 changes: 3 additions & 3 deletions topiary-core/tests/comment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ fn test_extract_comments() {
let mut expected_comments: Vec<AnchoredComment> = vec![
AnchoredComment {
comment_text: "(* starting comment *)".into(),
commented: CommentedAfter{
commented: CommentedAfter {
section: FUN_SECTION,
blank_line_after: false,
blank_line_before: false
blank_line_before: false,
},
original_column: 0,
},
Expand All @@ -74,7 +74,7 @@ fn test_extract_comments() {
},
AnchoredComment {
comment_text: "(** multi-lined\n * body comment\n *)".into(),
commented: CommentedAfter{
commented: CommentedAfter {
section: BODY_SECTION,
blank_line_after: false,
blank_line_before: false,
Expand Down

0 comments on commit a2990d4

Please sign in to comment.