File tree Expand file tree Collapse file tree 3 files changed +41
-5
lines changed Expand file tree Collapse file tree 3 files changed +41
-5
lines changed Original file line number Diff line number Diff line change @@ -836,14 +836,17 @@ impl<'a> FormatWrite<'a> for AstNode<'a, IfStatement<'a>> {
836836 }
837837
838838 if has_dangling_comments {
839- write ! (
840- f,
841- FormatDanglingComments :: Comments { comments, indent: DanglingIndentMode :: None }
842- ) ?;
843-
844839 if has_line_comment {
840+ write ! ( f, FormatTrailingComments :: Comments ( comments) ) ?;
845841 write ! ( f, hard_line_break( ) ) ?;
846842 } else {
843+ write ! (
844+ f,
845+ FormatDanglingComments :: Comments {
846+ comments,
847+ indent: DanglingIndentMode :: None
848+ }
849+ ) ?;
847850 write ! ( f, space( ) ) ?;
848851 }
849852 }
Original file line number Diff line number Diff line change 1+ if ( true ) { }
2+
3+ // comment1
4+ else if ( false ) { }
5+
6+ // comment2
7+
8+ else { }
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / oxc_formatter / tests / fixtures / mod .rs
3+ -- -
4+ ==================== Input ====================
5+ if (true ) {}
6+
7+ // comment1
8+ else if (false ) {}
9+
10+ // comment2
11+
12+ else {}
13+ ==================== Output ====================
14+ if (true ) {
15+ }
16+
17+ // comment1
18+ else if (false ) {
19+ }
20+
21+ // comment2
22+ else {
23+ }
24+
25+ ===================== End =====================
You can’t perform that action at this time.
0 commit comments