From a813062ed206b4382a1694ea6aef019f18733bca Mon Sep 17 00:00:00 2001 From: Ayomide Bamidele Date: Mon, 29 Mar 2021 12:20:26 +0100 Subject: Folding range for statics --- crates/ide/src/folding_ranges.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs index 8f3144de0..8b8a2cc38 100644 --- a/crates/ide/src/folding_ranges.rs +++ b/crates/ide/src/folding_ranges.rs @@ -33,6 +33,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec { let mut visited_imports = FxHashSet::default(); let mut visited_mods = FxHashSet::default(); let mut visited_consts = FxHashSet::default(); + let mut visited_statics = FxHashSet::default(); // regions can be nested, here is a LIFO buffer let mut regions_starts: Vec = vec![]; @@ -101,6 +102,12 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec { res.push(Fold { range, kind: FoldKind::Consts }) } } + // Fold groups of consts + if node.kind() == STATIC && !visited_statics.contains(&node) { + if let Some(range) = contiguous_range_for_group(&node, &mut visited_statics) { + res.push(Fold { range, kind: FoldKind::Statics }) + } + } } } } -- cgit v1.2.3