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.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 0b40bf9af..5b0b94e34 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -8,8 +8,9 @@ use hir_def::{
8}; 8};
9use ra_db::{FileId, FileRange}; 9use ra_db::{FileId, FileRange};
10use ra_syntax::{ 10use ra_syntax::{
11 algo::find_covering_element, ast, match_ast, AstNode, NodeOrToken, SyntaxElement, SyntaxNode, 11 algo::{find_covering_element, skip_trivia_token},
12 SyntaxToken, TextRange, TextUnit, 12 ast, match_ast, AstNode, Direction, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken,
13 TextRange, TextUnit,
13}; 14};
14use rustc_hash::{FxHashMap, FxHashSet}; 15use rustc_hash::{FxHashMap, FxHashSet};
15 16
@@ -384,11 +385,12 @@ fn original_range_and_origin(
384 }; 385 };
385 386
386 // the input node has only one token ? 387 // the input node has only one token ?
387 let single = node.value.first_token()? == node.value.last_token()?; 388 let single = skip_trivia_token(node.value.first_token()?, Direction::Next)?
389 == skip_trivia_token(node.value.last_token()?, Direction::Prev)?;
388 390
389 return Some(node.value.descendants().find_map(|it| { 391 return Some(node.value.descendants().find_map(|it| {
390 let first = it.first_token()?; 392 let first = skip_trivia_token(it.first_token()?, Direction::Next)?;
391 let last = it.last_token()?; 393 let last = skip_trivia_token(it.last_token()?, Direction::Prev)?;
392 394
393 if !single && first == last { 395 if !single && first == last {
394 return None; 396 return None;