aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src/search.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src/search.rs')
-rw-r--r--crates/ra_ide_db/src/search.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index 1bf014149..c66de4f42 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ra_ide_db/src/search.rs
@@ -10,7 +10,7 @@ use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility};
10use once_cell::unsync::Lazy; 10use once_cell::unsync::Lazy;
11use ra_db::{FileId, FileRange, SourceDatabaseExt}; 11use ra_db::{FileId, FileRange, SourceDatabaseExt};
12use ra_prof::profile; 12use ra_prof::profile;
13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextUnit}; 13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize};
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
15use test_utils::tested_by; 15use test_utils::tested_by;
16 16
@@ -85,7 +85,7 @@ impl SearchScope {
85 match (r1, r2) { 85 match (r1, r2) {
86 (None, r) | (r, None) => Some(r), 86 (None, r) | (r, None) => Some(r),
87 (Some(r1), Some(r2)) => { 87 (Some(r1), Some(r2)) => {
88 let r = r1.intersection(&r2)?; 88 let r = r1.intersect(r2)?;
89 Some(Some(r)) 89 Some(Some(r))
90 } 90 }
91 } 91 }
@@ -200,14 +200,13 @@ impl Definition {
200 200
201 for (file_id, search_range) in search_scope { 201 for (file_id, search_range) in search_scope {
202 let text = db.file_text(file_id); 202 let text = db.file_text(file_id);
203 let search_range = 203 let search_range = search_range.unwrap_or(TextRange::up_to(TextSize::of(&text)));
204 search_range.unwrap_or(TextRange::offset_len(0.into(), TextUnit::of_str(&text)));
205 204
206 let sema = Semantics::new(db); 205 let sema = Semantics::new(db);
207 let tree = Lazy::new(|| sema.parse(file_id).syntax().clone()); 206 let tree = Lazy::new(|| sema.parse(file_id).syntax().clone());
208 207
209 for (idx, _) in text.match_indices(pat) { 208 for (idx, _) in text.match_indices(pat) {
210 let offset = TextUnit::from_usize(idx); 209 let offset = TextSize::from_usize(idx);
211 if !search_range.contains_inclusive(offset) { 210 if !search_range.contains_inclusive(offset) {
212 tested_by!(search_filters_by_range; force); 211 tested_by!(search_filters_by_range; force);
213 continue; 212 continue;