mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Use smart case in flyimport items lookup
This commit is contained in:
parent
09412d85fc
commit
ec731e19df
3 changed files with 80 additions and 6 deletions
|
@ -52,6 +52,7 @@ pub struct Query {
|
|||
only_types: bool,
|
||||
libs: bool,
|
||||
exact: bool,
|
||||
case_sensitive: bool,
|
||||
limit: usize,
|
||||
}
|
||||
|
||||
|
@ -64,6 +65,7 @@ impl Query {
|
|||
only_types: false,
|
||||
libs: false,
|
||||
exact: false,
|
||||
case_sensitive: false,
|
||||
limit: usize::max_value(),
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +82,10 @@ impl Query {
|
|||
self.exact = true;
|
||||
}
|
||||
|
||||
pub fn case_sensitive(&mut self) {
|
||||
self.case_sensitive = true;
|
||||
}
|
||||
|
||||
pub fn limit(&mut self, limit: usize) {
|
||||
self.limit = limit
|
||||
}
|
||||
|
@ -326,8 +332,14 @@ impl Query {
|
|||
if self.only_types && !symbol.kind.is_type() {
|
||||
continue;
|
||||
}
|
||||
if self.exact && symbol.name != self.query {
|
||||
continue;
|
||||
if self.exact {
|
||||
if symbol.name != self.query {
|
||||
continue;
|
||||
}
|
||||
} else if self.case_sensitive {
|
||||
if self.query.chars().any(|c| !symbol.name.contains(c)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
res.push(symbol.clone());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue