aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/folding_ranges.rs8
-rw-r--r--crates/rust-analyzer/src/to_proto.rs2
2 files changed, 9 insertions, 1 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 }
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 530c8a5a4..a3799880f 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -492,7 +492,7 @@ pub(crate) fn folding_range(
492 FoldKind::Comment => Some(lsp_types::FoldingRangeKind::Comment), 492 FoldKind::Comment => Some(lsp_types::FoldingRangeKind::Comment),
493 FoldKind::Imports => Some(lsp_types::FoldingRangeKind::Imports), 493 FoldKind::Imports => Some(lsp_types::FoldingRangeKind::Imports),
494 FoldKind::Region => Some(lsp_types::FoldingRangeKind::Region), 494 FoldKind::Region => Some(lsp_types::FoldingRangeKind::Region),
495 FoldKind::Mods | FoldKind::Block | FoldKind::ArgList => None, 495 FoldKind::Mods | FoldKind::Block | FoldKind::ArgList | FoldKind::Consts | FoldKind::Statics => None,
496 }; 496 };
497 497
498 let range = range(line_index, fold.range); 498 let range = range(line_index, fold.range);