From 61fd6c6270f9ebc37f4156ae1a4d41053a78cdb1 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 27 Feb 2020 10:06:48 +0800 Subject: Use text_range::extend_to --- crates/ra_ide/src/extend_selection.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'crates/ra_ide') 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( .take_while(validate) .last()?; - let range = union_range(first.text_range(), last.text_range()); + let range = first.text_range().extend_to(&last.text_range()); if original_range.is_subrange(&range) && original_range != range { Some(range) } else { @@ -169,12 +169,6 @@ fn extend_tokens_from_range( } } -fn union_range(range: TextRange, r: TextRange) -> TextRange { - let start = range.start().min(r.start()); - let end = range.end().max(r.end()); - TextRange::from_to(start, end) -} - /// Find the shallowest node with same range, which allows us to traverse siblings. fn shallowest_node(node: &SyntaxNode) -> SyntaxNode { node.ancestors().take_while(|n| n.text_range() == node.text_range()).last().unwrap() -- cgit v1.2.3