From 391be072987bfccf2985a9d09623bbb73d60e3ff Mon Sep 17 00:00:00 2001 From: Ayomide Bamidele Date: Mon, 29 Mar 2021 12:17:19 +0100 Subject: Folding range for consts --- crates/ide/src/folding_ranges.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/ide') 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 { let mut visited_comments = FxHashSet::default(); let mut visited_imports = FxHashSet::default(); let mut visited_mods = FxHashSet::default(); + let mut visited_consts = FxHashSet::default(); // regions can be nested, here is a LIFO buffer let mut regions_starts: Vec = vec![]; @@ -93,6 +94,13 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec { res.push(Fold { range, kind: FoldKind::Mods }) } } + + // Fold groups of consts + if node.kind() == CONST && !visited_consts.contains(&node) { + if let Some(range) = contiguous_range_for_group(&node, &mut visited_consts) { + res.push(Fold { range, kind: FoldKind::Consts }) + } + } } } } -- cgit v1.2.3