Don't overflow when limiting symbol search
This commit is contained in:
parent
7daaddb2ac
commit
df05c5c3e2
@ -42,7 +42,7 @@ pub(crate) fn for_file(file_id: FileId, file: File) -> SymbolIndex {
|
||||
|
||||
impl Query {
|
||||
pub(crate) fn search(
|
||||
mut self,
|
||||
self,
|
||||
indices: &[&SymbolIndex],
|
||||
token: &JobToken,
|
||||
) -> Vec<(FileId, FileSymbol)> {
|
||||
@ -55,7 +55,7 @@ pub(crate) fn search(
|
||||
let mut stream = op.union();
|
||||
let mut res = Vec::new();
|
||||
while let Some((_, indexed_values)) = stream.next() {
|
||||
if self.limit == 0 || token.is_canceled() {
|
||||
if res.len() >= self.limit || token.is_canceled() {
|
||||
break;
|
||||
}
|
||||
for indexed_value in indexed_values {
|
||||
@ -70,7 +70,6 @@ pub(crate) fn search(
|
||||
continue;
|
||||
}
|
||||
res.push((*file_id, symbol.clone()));
|
||||
self.limit -= 1;
|
||||
}
|
||||
}
|
||||
res
|
||||
|
Loading…
Reference in New Issue
Block a user