aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-08 13:39:28 +0100
committerAleksey Kladov <[email protected]>2018-09-08 13:39:28 +0100
commitdf05c5c3e20cfdfccd0165dd3370fed7c3676cd0 (patch)
tree9750bd3135a71d2f178e53991b9e3cb3b795200c
parent7daaddb2ac281dcad3ac99496b1cf3f06840887d (diff)
Don't overflow when limiting symbol search
-rw-r--r--crates/libanalysis/src/symbol_index.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/libanalysis/src/symbol_index.rs b/crates/libanalysis/src/symbol_index.rs
index 8fef326ab..4c93761aa 100644
--- a/crates/libanalysis/src/symbol_index.rs
+++ b/crates/libanalysis/src/symbol_index.rs
@@ -42,7 +42,7 @@ impl SymbolIndex {
42 42
43impl Query { 43impl Query {
44 pub(crate) fn search( 44 pub(crate) fn search(
45 mut self, 45 self,
46 indices: &[&SymbolIndex], 46 indices: &[&SymbolIndex],
47 token: &JobToken, 47 token: &JobToken,
48 ) -> Vec<(FileId, FileSymbol)> { 48 ) -> Vec<(FileId, FileSymbol)> {
@@ -55,7 +55,7 @@ impl Query {
55 let mut stream = op.union(); 55 let mut stream = op.union();
56 let mut res = Vec::new(); 56 let mut res = Vec::new();
57 while let Some((_, indexed_values)) = stream.next() { 57 while let Some((_, indexed_values)) = stream.next() {
58 if self.limit == 0 || token.is_canceled() { 58 if res.len() >= self.limit || token.is_canceled() {
59 break; 59 break;
60 } 60 }
61 for indexed_value in indexed_values { 61 for indexed_value in indexed_values {
@@ -70,7 +70,6 @@ impl Query {
70 continue; 70 continue;
71 } 71 }
72 res.push((*file_id, symbol.clone())); 72 res.push((*file_id, symbol.clone()));
73 self.limit -= 1;
74 } 73 }
75 } 74 }
76 res 75 res