diff options
author | Ayomide Bamidele <[email protected]> | 2021-03-29 12:17:19 +0100 |
---|---|---|
committer | Ayomide Bamidele <[email protected]> | 2021-03-29 12:17:19 +0100 |
commit | 391be072987bfccf2985a9d09623bbb73d60e3ff (patch) | |
tree | 85b22cd4c3a9f677ed4b6e32678d45962daaf518 /crates | |
parent | 23601454fe3467eccdcc6393145bfd0858bd84cb (diff) |
Folding range for consts
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/folding_ranges.rs | 8 | ||||
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 2 |
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); |