aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/folding_ranges.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/folding_ranges.rs')
-rw-r--r--crates/ra_editor/src/folding_ranges.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs
index 817da28d1..733512368 100644
--- a/crates/ra_editor/src/folding_ranges.rs
+++ b/crates/ra_editor/src/folding_ranges.rs
@@ -3,7 +3,7 @@ use std::collections::HashSet;
3use ra_syntax::{ 3use ra_syntax::{
4 File, TextRange, SyntaxNodeRef, 4 File, TextRange, SyntaxNodeRef,
5 SyntaxKind, 5 SyntaxKind,
6 algo::{walk, Direction, siblings}, 6 Direction,
7}; 7};
8 8
9#[derive(Debug, PartialEq, Eq)] 9#[derive(Debug, PartialEq, Eq)]
@@ -19,12 +19,10 @@ pub struct Fold {
19} 19}
20 20
21pub fn folding_ranges(file: &File) -> Vec<Fold> { 21pub fn folding_ranges(file: &File) -> Vec<Fold> {
22 let syntax = file.syntax();
23
24 let mut res = vec![]; 22 let mut res = vec![];
25 let mut visited = HashSet::new(); 23 let mut visited = HashSet::new();
26 24
27 for node in walk::preorder(syntax) { 25 for node in file.syntax().descendants() {
28 if visited.contains(&node) { 26 if visited.contains(&node) {
29 continue; 27 continue;
30 } 28 }
@@ -64,7 +62,7 @@ fn contiguous_range_for<'a>(
64 62
65 let left = node; 63 let left = node;
66 let mut right = node; 64 let mut right = node;
67 for node in siblings(node, Direction::Forward) { 65 for node in node.siblings(Direction::Next) {
68 visited.insert(node); 66 visited.insert(node);
69 match node.kind() { 67 match node.kind() {
70 SyntaxKind::WHITESPACE if !node.leaf_text().unwrap().as_str().contains("\n\n") => (), 68 SyntaxKind::WHITESPACE if !node.leaf_text().unwrap().as_str().contains("\n\n") => (),
@@ -139,4 +137,4 @@ fn main() {
139 } 137 }
140 138
141 139
142} \ No newline at end of file 140}