mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Don't overflow when limiting symbol search
This commit is contained in:
parent
7daaddb2ac
commit
df05c5c3e2
1 changed files with 2 additions and 3 deletions
|
@ -42,7 +42,7 @@ impl SymbolIndex {
|
||||||
|
|
||||||
impl Query {
|
impl Query {
|
||||||
pub(crate) fn search(
|
pub(crate) fn search(
|
||||||
mut self,
|
self,
|
||||||
indices: &[&SymbolIndex],
|
indices: &[&SymbolIndex],
|
||||||
token: &JobToken,
|
token: &JobToken,
|
||||||
) -> Vec<(FileId, FileSymbol)> {
|
) -> Vec<(FileId, FileSymbol)> {
|
||||||
|
@ -55,7 +55,7 @@ impl Query {
|
||||||
let mut stream = op.union();
|
let mut stream = op.union();
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
while let Some((_, indexed_values)) = stream.next() {
|
while let Some((_, indexed_values)) = stream.next() {
|
||||||
if self.limit == 0 || token.is_canceled() {
|
if res.len() >= self.limit || token.is_canceled() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for indexed_value in indexed_values {
|
for indexed_value in indexed_values {
|
||||||
|
@ -70,7 +70,6 @@ impl Query {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
res.push((*file_id, symbol.clone()));
|
res.push((*file_id, symbol.clone()));
|
||||||
self.limit -= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
|
|
Loading…
Reference in a new issue