diff options
Diffstat (limited to 'crates/ra_editor/src/extend_selection.rs')
-rw-r--r-- | crates/ra_editor/src/extend_selection.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_editor/src/extend_selection.rs b/crates/ra_editor/src/extend_selection.rs index 2f8a04b2b..b00a457b9 100644 --- a/crates/ra_editor/src/extend_selection.rs +++ b/crates/ra_editor/src/extend_selection.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | File, TextRange, SyntaxNodeRef, TextUnit, | 2 | File, TextRange, SyntaxNodeRef, TextUnit, Direction, |
3 | SyntaxKind::*, | 3 | SyntaxKind::*, |
4 | algo::{find_leaf_at_offset, LeafAtOffset, find_covering_node, Direction, siblings}, | 4 | algo::{find_leaf_at_offset, LeafAtOffset, find_covering_node}, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | pub fn extend_selection(file: &File, range: TextRange) -> Option<TextRange> { | 7 | pub fn extend_selection(file: &File, range: TextRange) -> Option<TextRange> { |
@@ -71,12 +71,12 @@ fn pick_best<'a>(l: SyntaxNodeRef<'a>, r: SyntaxNodeRef<'a>) -> SyntaxNodeRef<'a | |||
71 | } | 71 | } |
72 | 72 | ||
73 | fn extend_comments(node: SyntaxNodeRef) -> Option<TextRange> { | 73 | fn extend_comments(node: SyntaxNodeRef) -> Option<TextRange> { |
74 | let left = adj_comments(node, Direction::Backward); | 74 | let prev = adj_comments(node, Direction::Prev); |
75 | let right = adj_comments(node, Direction::Forward); | 75 | let next = adj_comments(node, Direction::Next); |
76 | if left != right { | 76 | if prev != next { |
77 | Some(TextRange::from_to( | 77 | Some(TextRange::from_to( |
78 | left.range().start(), | 78 | prev.range().start(), |
79 | right.range().end(), | 79 | next.range().end(), |
80 | )) | 80 | )) |
81 | } else { | 81 | } else { |
82 | None | 82 | None |
@@ -85,7 +85,7 @@ fn extend_comments(node: SyntaxNodeRef) -> Option<TextRange> { | |||
85 | 85 | ||
86 | fn adj_comments(node: SyntaxNodeRef, dir: Direction) -> SyntaxNodeRef { | 86 | fn adj_comments(node: SyntaxNodeRef, dir: Direction) -> SyntaxNodeRef { |
87 | let mut res = node; | 87 | let mut res = node; |
88 | for node in siblings(node, dir) { | 88 | for node in node.siblings(dir) { |
89 | match node.kind() { | 89 | match node.kind() { |
90 | COMMENT => res = node, | 90 | COMMENT => res = node, |
91 | WHITESPACE if !node.leaf_text().unwrap().as_str().contains("\n\n") => (), | 91 | WHITESPACE if !node.leaf_text().unwrap().as_str().contains("\n\n") => (), |