aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorAyomide Bamidele <[email protected]>2021-03-29 12:17:19 +0100
committerAyomide Bamidele <[email protected]>2021-03-29 12:17:19 +0100
commit391be072987bfccf2985a9d09623bbb73d60e3ff (patch)
tree85b22cd4c3a9f677ed4b6e32678d45962daaf518 /crates/ide
parent23601454fe3467eccdcc6393145bfd0858bd84cb (diff)
Folding range for consts
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/folding_ranges.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs
index 1dd37483f..8f3144de0 100644
--- a/crates/ide/src/folding_ranges.rs
+++ b/crates/ide/src/folding_ranges.rs
@@ -32,6 +32,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
32 let mut visited_comments = FxHashSet::default(); 32 let mut visited_comments = FxHashSet::default();
33 let mut visited_imports = FxHashSet::default(); 33 let mut visited_imports = FxHashSet::default();
34 let mut visited_mods = FxHashSet::default(); 34 let mut visited_mods = FxHashSet::default();
35 let mut visited_consts = FxHashSet::default();
35 // regions can be nested, here is a LIFO buffer 36 // regions can be nested, here is a LIFO buffer
36 let mut regions_starts: Vec<TextSize> = vec![]; 37 let mut regions_starts: Vec<TextSize> = vec![];
37 38
@@ -93,6 +94,13 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
93 res.push(Fold { range, kind: FoldKind::Mods }) 94 res.push(Fold { range, kind: FoldKind::Mods })
94 } 95 }
95 } 96 }
97
98 // Fold groups of consts
99 if node.kind() == CONST && !visited_consts.contains(&node) {
100 if let Some(range) = contiguous_range_for_group(&node, &mut visited_consts) {
101 res.push(Fold { range, kind: FoldKind::Consts })
102 }
103 }
96 } 104 }
97 } 105 }
98 } 106 }