diff options
author | Aleksey Kladov <[email protected]> | 2020-02-26 16:58:32 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-26 16:58:32 +0000 |
commit | 913cdcee8f0fe4373627d10d756949b970bcf5c2 (patch) | |
tree | 7f0e57819a98bb908d4511d1c57ea484520373e3 /crates/ra_hir | |
parent | 6ea633c4940d25acea04e4945a8f905e65153c30 (diff) | |
parent | 553254973e24a2c0bdf1475fccbbc4603e8421f0 (diff) |
Merge pull request #3325 from edwin0cheng/skip-trival-token
Skip trival token in original_range
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 12 |
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 | }; |
9 | use ra_db::{FileId, FileRange}; | 9 | use ra_db::{FileId, FileRange}; |
10 | use ra_syntax::{ | 10 | use 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 | }; |
14 | use rustc_hash::{FxHashMap, FxHashSet}; | 15 | use 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; |