Update crates/ide/src/folding_ranges.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
Luciano 2021-02-13 17:46:26 +01:00 committed by GitHub
parent 084b21bc36
commit 75015b6eaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,10 +55,10 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
if comment.text().trim().starts_with("// region:") {
regions_starts.push(comment.syntax().text_range().start());
} else if comment.text().trim().starts_with("// endregion") {
if !regions_starts.is_empty() {
if let Some(region) = regions_starts.pop() {
res.push(Fold {
range: TextRange::new(
regions_starts.pop().unwrap(),
region,
comment.syntax().text_range().end(),
),
kind: FoldKind::Region,