File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -659,7 +659,7 @@ impl<'a> FormatWrite<'a> for AstNode<'a, ForStatement<'a>> {
659659
660660impl < ' a > FormatWrite < ' a > for AstNode < ' a , ForInStatement < ' a > > {
661661 fn write ( & self , f : & mut Formatter < ' _ , ' a > ) -> FormatResult < ( ) > {
662- let comments = f. context ( ) . comments ( ) . own_line_comments_before ( self . body . span ( ) . start ) ;
662+ let comments = f. context ( ) . comments ( ) . own_line_comments_before ( self . right . span ( ) . start ) ;
663663 write ! (
664664 f,
665665 [
@@ -683,7 +683,7 @@ impl<'a> FormatWrite<'a> for AstNode<'a, ForInStatement<'a>> {
683683
684684impl < ' a > FormatWrite < ' a > for AstNode < ' a , ForOfStatement < ' a > > {
685685 fn write ( & self , f : & mut Formatter < ' _ , ' a > ) -> FormatResult < ( ) > {
686- let comments = f. context ( ) . comments ( ) . own_line_comments_before ( self . body . span ( ) . start ) ;
686+ let comments = f. context ( ) . comments ( ) . own_line_comments_before ( self . right . span ( ) . start ) ;
687687
688688 let r#await = self . r#await ( ) ;
689689 let left = self . left ( ) ;
Original file line number Diff line number Diff line change 1+ for ( let i in [
2+ // comment1
3+ 1 , 2 , 3
4+ // comment2
5+ ] ) ;
6+
7+ for ( let i of [
8+ // comment1
9+ 1 , 2 , 3
10+ // comment2
11+ ] ) ;
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / oxc_formatter / tests / fixtures / mod .rs
3+ -- -
4+ ==================== Input ====================
5+ for (let i in [
6+ // comment1
7+ 1 , 2 , 3
8+ // comment2
9+ ]);
10+
11+ for (let i of [
12+ // comment1
13+ 1 , 2 , 3
14+ // comment2
15+ ]);
16+ ==================== Output ====================
17+ for (let i in [
18+ // comment1
19+ 1 , 2 ,
20+ 3 ,
21+ // comment2
22+ ]);
23+
24+ for (let i of [
25+ // comment1
26+ 1 , 2 ,
27+ 3 ,
28+ // comment2
29+ ]);
30+
31+ ===================== End =====================
You can’t perform that action at this time.
0 commit comments