@@ -92,12 +92,18 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
92
92
}
93
93
94
94
// Fold groups of mods
95
- if node . kind ( ) == MODULE && ! has_visibility ( & node) && !visited_mods . contains ( & node )
96
- {
97
- if let Some ( range ) =
98
- contiguous_range_for_group_unless ( & node , has_visibility , & mut visited_mods )
95
+ if let Some ( module ) = ast :: Module :: cast ( node. clone ( ) ) {
96
+ if ! has_visibility ( & node )
97
+ && !visited_mods . contains ( & node )
98
+ && module . item_list ( ) . is_none ( )
99
99
{
100
- res. push ( Fold { range, kind : FoldKind :: Mods } )
100
+ if let Some ( range) = contiguous_range_for_group_unless (
101
+ & node,
102
+ has_visibility,
103
+ & mut visited_mods,
104
+ ) {
105
+ res. push ( Fold { range, kind : FoldKind :: Mods } )
106
+ }
101
107
}
102
108
}
103
109
@@ -328,7 +334,8 @@ fn main() <fold block>{
328
334
//! because it has another flavor</fold>
329
335
<fold comment>/* As does this
330
336
multiline comment */</fold>
331
- }</fold>"# ,
337
+ }</fold>
338
+ "# ,
332
339
) ;
333
340
}
334
341
@@ -341,9 +348,7 @@ use std::<fold block>{
341
348
vec,
342
349
io as iop
343
350
}</fold>;
344
-
345
- fn main() <fold block>{
346
- }</fold>"# ,
351
+ "# ,
347
352
) ;
348
353
}
349
354
@@ -368,8 +373,13 @@ pub not_folding_single_next;
368
373
mod with_attribute;
369
374
mod with_attribute_next;</fold>
370
375
371
- fn main() <fold block>{
372
- }</fold>"# ,
376
+ mod inline0 {}
377
+ mod inline1 {}
378
+
379
+ mod inline2 <fold block>{
380
+
381
+ }</fold>
382
+ "# ,
373
383
) ;
374
384
}
375
385
@@ -387,9 +397,7 @@ use std::f64;</fold>
387
397
<fold imports>use std::collections::HashMap;
388
398
// Some random comment
389
399
use std::collections::VecDeque;</fold>
390
-
391
- fn main() <fold block>{
392
- }</fold>"# ,
400
+ "# ,
393
401
) ;
394
402
}
395
403
@@ -409,9 +417,7 @@ use std::collections::<fold block>{
409
417
VecDeque,
410
418
}</fold>;
411
419
// Some random comment
412
-
413
- fn main() <fold block>{
414
- }</fold>"# ,
420
+ "# ,
415
421
) ;
416
422
}
417
423
@@ -531,7 +537,7 @@ calling_function(x,y);
531
537
r#"
532
538
<fold consts>const FIRST_CONST: &str = "first";
533
539
const SECOND_CONST: &str = "second";</fold>
534
- "#,
540
+ "# ,
535
541
)
536
542
}
537
543
@@ -541,7 +547,7 @@ const SECOND_CONST: &str = "second";</fold>
541
547
r#"
542
548
<fold statics>static FIRST_STATIC: &str = "first";
543
549
static SECOND_STATIC: &str = "second";</fold>
544
- "#,
550
+ "# ,
545
551
)
546
552
}
547
553
@@ -574,7 +580,7 @@ fn foo()<fold returntype>-> (
574
580
)</fold> { (true, true) }
575
581
576
582
fn bar() -> (bool, bool) { (true, true) }
577
- "#,
583
+ "# ,
578
584
)
579
585
}
580
586
}
0 commit comments