mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Use text_range::extend_to
This commit is contained in:
parent
05388b4ea4
commit
61fd6c6270
4 changed files with 6 additions and 19 deletions
|
@ -388,7 +388,7 @@ fn original_range_and_origin(
|
|||
let single = skip_trivia_token(node.value.first_token()?, Direction::Next)?
|
||||
== skip_trivia_token(node.value.last_token()?, Direction::Prev)?;
|
||||
|
||||
return Some(node.value.descendants().find_map(|it| {
|
||||
Some(node.value.descendants().find_map(|it| {
|
||||
let first = skip_trivia_token(it.first_token()?, Direction::Next)?;
|
||||
let last = skip_trivia_token(it.last_token()?, Direction::Prev)?;
|
||||
|
||||
|
@ -404,16 +404,9 @@ fn original_range_and_origin(
|
|||
return None;
|
||||
}
|
||||
|
||||
// FIXME: Add union method in TextRange
|
||||
Some((
|
||||
first.with_value(union_range(first.value.text_range(), last.value.text_range())),
|
||||
first.with_value(first.value.text_range().extend_to(&last.value.text_range())),
|
||||
first_origin,
|
||||
))
|
||||
})?);
|
||||
|
||||
fn union_range(a: TextRange, b: TextRange) -> TextRange {
|
||||
let start = a.start().min(b.start());
|
||||
let end = a.end().max(b.end());
|
||||
TextRange::from_to(start, end)
|
||||
}
|
||||
})?)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue