mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 12:36:47 +00:00
Folding range for consts
This commit is contained in:
parent
23601454fe
commit
391be07298
@ -32,6 +32,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
|
||||
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<TextSize> = vec![];
|
||||
|
||||
@ -93,6 +94,13 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
|
||||
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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ pub(crate) fn folding_range(
|
||||
FoldKind::Comment => Some(lsp_types::FoldingRangeKind::Comment),
|
||||
FoldKind::Imports => Some(lsp_types::FoldingRangeKind::Imports),
|
||||
FoldKind::Region => Some(lsp_types::FoldingRangeKind::Region),
|
||||
FoldKind::Mods | FoldKind::Block | FoldKind::ArgList => None,
|
||||
FoldKind::Mods | FoldKind::Block | FoldKind::ArgList | FoldKind::Consts | FoldKind::Statics => None,
|
||||
};
|
||||
|
||||
let range = range(line_index, fold.range);
|
||||
|
Loading…
Reference in New Issue
Block a user