mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Don't fold consecutive modules with item lists
This commit is contained in:
parent
190f37afab
commit
658514d378
1 changed files with 26 additions and 20 deletions
|
@ -92,14 +92,20 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
|
|||
}
|
||||
|
||||
// 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()
|
||||
{
|
||||
if let Some(range) = contiguous_range_for_group_unless(
|
||||
&node,
|
||||
has_visibility,
|
||||
&mut visited_mods,
|
||||
) {
|
||||
res.push(Fold { range, kind: FoldKind::Mods })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fold groups of consts
|
||||
if node.kind() == CONST && !visited_consts.contains(&node) {
|
||||
|
@ -328,7 +334,8 @@ fn main() <fold block>{
|
|||
//! because it has another flavor</fold>
|
||||
<fold comment>/* As does this
|
||||
multiline comment */</fold>
|
||||
}</fold>"#,
|
||||
}</fold>
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -341,9 +348,7 @@ use std::<fold block>{
|
|||
vec,
|
||||
io as iop
|
||||
}</fold>;
|
||||
|
||||
fn main() <fold block>{
|
||||
}</fold>"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -368,8 +373,13 @@ pub not_folding_single_next;
|
|||
mod with_attribute;
|
||||
mod with_attribute_next;</fold>
|
||||
|
||||
fn main() <fold block>{
|
||||
}</fold>"#,
|
||||
mod inline0 {}
|
||||
mod inline1 {}
|
||||
|
||||
mod inline2 <fold block>{
|
||||
|
||||
}</fold>
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -387,9 +397,7 @@ use std::f64;</fold>
|
|||
<fold imports>use std::collections::HashMap;
|
||||
// Some random comment
|
||||
use std::collections::VecDeque;</fold>
|
||||
|
||||
fn main() <fold block>{
|
||||
}</fold>"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -409,9 +417,7 @@ use std::collections::<fold block>{
|
|||
VecDeque,
|
||||
}</fold>;
|
||||
// Some random comment
|
||||
|
||||
fn main() <fold block>{
|
||||
}</fold>"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue