diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-27 02:08:19 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-27 02:08:19 +0000 |
commit | 13e16a4ad4c32501472d6b1805ada19b62658135 (patch) | |
tree | 714d8787e9f26bf2e57aaf6bd1aa14d70f6abde0 /crates/ra_ide | |
parent | 05388b4ea46c886fa4ec8a1d49b71eb816cf7c6d (diff) | |
parent | 61fd6c6270f9ebc37f4156ae1a4d41053a78cdb1 (diff) |
Merge #3336
3336: Use text_range::extend_to r=edwin0cheng a=edwin0cheng
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/extend_selection.rs | 8 |
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 | ||
172 | fn 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. |
179 | fn shallowest_node(node: &SyntaxNode) -> SyntaxNode { | 173 | fn 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() |