aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-02-27 02:06:48 +0000
committerEdwin Cheng <[email protected]>2020-02-27 02:06:48 +0000
commit61fd6c6270f9ebc37f4156ae1a4d41053a78cdb1 (patch)
tree714d8787e9f26bf2e57aaf6bd1aa14d70f6abde0 /crates/ra_ide/src
parent05388b4ea46c886fa4ec8a1d49b71eb816cf7c6d (diff)
Use text_range::extend_to
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/extend_selection.rs8
1 files changed, 1 insertions, 7 deletions
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index 2e09bd1ec..f5a063351 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -161,7 +161,7 @@ fn extend_tokens_from_range(
161 .take_while(validate) 161 .take_while(validate)
162 .last()?; 162 .last()?;
163 163
164 let range = union_range(first.text_range(), last.text_range()); 164 let range = first.text_range().extend_to(&last.text_range());
165 if original_range.is_subrange(&range) && original_range != range { 165 if original_range.is_subrange(&range) && original_range != range {
166 Some(range) 166 Some(range)
167 } else { 167 } else {
@@ -169,12 +169,6 @@ fn extend_tokens_from_range(
169 } 169 }
170} 170}
171 171
172fn union_range(range: TextRange, r: TextRange) -> TextRange {
173 let start = range.start().min(r.start());
174 let end = range.end().max(r.end());
175 TextRange::from_to(start, end)
176}
177
178/// Find the shallowest node with same range, which allows us to traverse siblings. 172/// Find the shallowest node with same range, which allows us to traverse siblings.
179fn shallowest_node(node: &SyntaxNode) -> SyntaxNode { 173fn shallowest_node(node: &SyntaxNode) -> SyntaxNode {
180 node.ancestors().take_while(|n| n.text_range() == node.text_range()).last().unwrap() 174 node.ancestors().take_while(|n| n.text_range() == node.text_range()).last().unwrap()