aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/semantics.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 5b0b94e34..c3d8ee1ae 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -388,7 +388,7 @@ fn original_range_and_origin(
388 let single = skip_trivia_token(node.value.first_token()?, Direction::Next)? 388 let single = skip_trivia_token(node.value.first_token()?, Direction::Next)?
389 == skip_trivia_token(node.value.last_token()?, Direction::Prev)?; 389 == skip_trivia_token(node.value.last_token()?, Direction::Prev)?;
390 390
391 return Some(node.value.descendants().find_map(|it| { 391 Some(node.value.descendants().find_map(|it| {
392 let first = skip_trivia_token(it.first_token()?, Direction::Next)?; 392 let first = skip_trivia_token(it.first_token()?, Direction::Next)?;
393 let last = skip_trivia_token(it.last_token()?, Direction::Prev)?; 393 let last = skip_trivia_token(it.last_token()?, Direction::Prev)?;
394 394
@@ -404,16 +404,9 @@ fn original_range_and_origin(
404 return None; 404 return None;
405 } 405 }
406 406
407 // FIXME: Add union method in TextRange
408 Some(( 407 Some((
409 first.with_value(union_range(first.value.text_range(), last.value.text_range())), 408 first.with_value(first.value.text_range().extend_to(&last.value.text_range())),
410 first_origin, 409 first_origin,
411 )) 410 ))
412 })?); 411 })?)
413
414 fn union_range(a: TextRange, b: TextRange) -> TextRange {
415 let start = a.start().min(b.start());
416 let end = a.end().max(b.end());
417 TextRange::from_to(start, end)
418 }
419} 412}