File tree Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -143,8 +143,14 @@ export default (options = {}) => {
143
143
const comment = comments [ comment_index ] ;
144
144
145
145
if ( comment && before ( comment . loc . start , loc ) ) {
146
- context . newline ( ) ;
147
146
write_comment ( comment , context ) ;
147
+
148
+ if ( comment . loc . end . line < loc . line ) {
149
+ context . newline ( ) ;
150
+ } else {
151
+ context . write ( ' ' ) ;
152
+ }
153
+
148
154
comment_index += 1 ;
149
155
} else {
150
156
break ;
@@ -260,6 +266,7 @@ export default (options = {}) => {
260
266
}
261
267
262
268
if ( node . loc ) {
269
+ context . newline ( ) ;
263
270
flush_comments_until ( context , node . loc . end ) ;
264
271
}
265
272
}
@@ -521,22 +528,8 @@ export default (options = {}) => {
521
528
_ ( node , context , visit ) {
522
529
const is_statement = / ( S t a t e m e n t | D e c l a r a t i o n ) $ / . test ( node . type ) ;
523
530
524
- while ( comment_index < comments . length ) {
525
- const comment = comments [ comment_index ] ;
526
-
527
- if ( before ( comment . loc . start , node . loc . start ) ) {
528
- write_comment ( comment , context ) ;
529
-
530
- if ( comment . loc . start . line < node . loc . start . line ) {
531
- context . newline ( ) ;
532
- } else {
533
- context . write ( ' ' ) ;
534
- }
535
-
536
- comment_index += 1 ;
537
- } else {
538
- break ;
539
- }
531
+ if ( node . loc ) {
532
+ flush_comments_until ( context , node . loc . start ) ;
540
533
}
541
534
542
535
visit ( node ) ;
You can’t perform that action at this time.
0 commit comments