From 75015b6eaaad6cb6ce511cff2f3f1e5e34450106 Mon Sep 17 00:00:00 2001 From: Luciano <31509965+LucianoBestia@users.noreply.github.com> Date: Sat, 13 Feb 2021 17:46:26 +0100 Subject: Update crates/ide/src/folding_ranges.rs Co-authored-by: Lukas Wirth --- crates/ide/src/folding_ranges.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs index 7ba775a77..531f3c951 100644 --- a/crates/ide/src/folding_ranges.rs +++ b/crates/ide/src/folding_ranges.rs @@ -55,10 +55,10 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec { 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, -- cgit v1.2.3