diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs
index c5015a34555..60f552fd92b 100755
--- a/crates/ide/src/folding_ranges.rs
+++ b/crates/ide/src/folding_ranges.rs
@@ -92,12 +92,18 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec {
}
// Fold groups of mods
- if node.kind() == MODULE && !has_visibility(&node) && !visited_mods.contains(&node)
- {
- if let Some(range) =
- contiguous_range_for_group_unless(&node, has_visibility, &mut visited_mods)
+ if let Some(module) = ast::Module::cast(node.clone()) {
+ if !has_visibility(&node)
+ && !visited_mods.contains(&node)
+ && module.item_list().is_none()
{
- res.push(Fold { range, kind: FoldKind::Mods })
+ if let Some(range) = contiguous_range_for_group_unless(
+ &node,
+ has_visibility,
+ &mut visited_mods,
+ ) {
+ res.push(Fold { range, kind: FoldKind::Mods })
+ }
}
}
@@ -328,7 +334,8 @@ fn main() {
//! because it has another flavor
/* As does this
multiline comment */
-}"#,
+}
+"#,
);
}
@@ -341,9 +348,7 @@ use std::{
vec,
io as iop
};
-
-fn main() {
-}"#,
+"#,
);
}
@@ -368,8 +373,13 @@ pub not_folding_single_next;
mod with_attribute;
mod with_attribute_next;
-fn main() {
-}"#,
+mod inline0 {}
+mod inline1 {}
+
+mod inline2 {
+
+}
+"#,
);
}
@@ -387,9 +397,7 @@ use std::f64;
use std::collections::HashMap;
// Some random comment
use std::collections::VecDeque;
-
-fn main() {
-}"#,
+"#,
);
}
@@ -409,9 +417,7 @@ use std::collections::{
VecDeque,
};
// Some random comment
-
-fn main() {
-}"#,
+"#,
);
}
@@ -531,7 +537,7 @@ calling_function(x,y);
r#"
const FIRST_CONST: &str = "first";
const SECOND_CONST: &str = "second";
- "#,
+"#,
)
}
@@ -541,7 +547,7 @@ const SECOND_CONST: &str = "second";
r#"
static FIRST_STATIC: &str = "first";
static SECOND_STATIC: &str = "second";
- "#,
+"#,
)
}
@@ -574,7 +580,7 @@ fn foo()-> (
) { (true, true) }
fn bar() -> (bool, bool) { (true, true) }
- "#,
+"#,
)
}
}