@@ -407,18 +407,32 @@ impl<'ast> State<'_, 'ast> {
407
407
408
408
print ( self , value) ;
409
409
410
+ let next_span = if is_last { None } else { Some ( get_span ( & values[ i + 1 ] ) ) } ;
411
+ let next_pos = next_span. map ( Span :: lo) . unwrap_or ( pos_hi) ;
412
+ let cmnt_before_next =
413
+ self . peek_comment_before ( next_pos) . map ( |cmnt| ( cmnt. span , cmnt. style ) ) ;
414
+
410
415
if !is_last {
416
+ // Handle disabled lines with comments after the value, but before the comma.
417
+ if cmnt_before_next. is_some_and ( |( cmnt_span, _) | {
418
+ let span = self . cursor . span ( cmnt_span. lo ( ) ) ;
419
+ self . inline_config . is_disabled ( span)
420
+ // NOTE: necessary workaround to patch this edgecase due to lack of spans for the commas.
421
+ && self . sm . span_to_snippet ( span) . is_ok_and ( |snip| !snip. contains ( ',' ) )
422
+ } ) {
423
+ self . print_comments (
424
+ next_pos,
425
+ CommentConfig :: skip_ws ( ) . mixed_no_break ( ) . mixed_prev_space ( ) ,
426
+ ) ;
427
+ }
411
428
self . print_word ( "," ) ;
412
429
}
413
430
414
- let next_span = if is_last { None } else { Some ( get_span ( & values[ i + 1 ] ) ) } ;
415
- let next_pos = next_span. map ( Span :: lo) . unwrap_or ( pos_hi) ;
416
-
417
431
if !is_last
418
432
&& format. breaks_cmnts
419
- && self . peek_comment_before ( next_pos ) . is_some_and ( |cmnt | {
420
- let disabled = self . inline_config . is_disabled ( cmnt . span ) ;
421
- ( cmnt . style . is_mixed ( ) && !disabled) || ( cmnt . style . is_isolated ( ) && disabled)
433
+ && cmnt_before_next . is_some_and ( |( cmnt_span , cmnt_style ) | {
434
+ let disabled = self . inline_config . is_disabled ( cmnt_span ) ;
435
+ ( cmnt_style . is_mixed ( ) && !disabled) || ( cmnt_style . is_isolated ( ) && disabled)
422
436
} )
423
437
{
424
438
self . hardbreak ( ) ; // trailing and isolated comments already hardbreak
0 commit comments