aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-11-02 17:48:19 +0000
committerJonas Schievink <[email protected]>2020-11-02 17:49:54 +0000
commit285960aa6ba1128b3e0658934f405dde81ce5f56 (patch)
treec23e46331017909d5d8125142db17a1802952db3 /crates
parent2bd26e6afcdd7a75e1256987e5e3b460451dfff4 (diff)
Fix coalescing of prime_caches updates
The previous implementation could try to create a progress bar when one was already registered
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index e9d08ff15..d504572a8 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -192,8 +192,7 @@ impl GlobalState {
192 }, 192 },
193 Event::Task(mut task) => { 193 Event::Task(mut task) => {
194 let _p = profile::span("GlobalState::handle_event/task"); 194 let _p = profile::span("GlobalState::handle_event/task");
195 let mut prime_caches_started = false; 195 let mut prime_caches_progress = Vec::new();
196 let mut prime_caches_progress = None;
197 loop { 196 loop {
198 match task { 197 match task {
199 Task::Response(response) => self.respond(response), 198 Task::Response(response) => self.respond(response),
@@ -203,13 +202,19 @@ impl GlobalState {
203 } 202 }
204 } 203 }
205 Task::Workspaces(workspaces) => self.switch_workspaces(workspaces), 204 Task::Workspaces(workspaces) => self.switch_workspaces(workspaces),
206 Task::PrimeCaches(progress) => { 205 Task::PrimeCaches(progress) => match progress {
207 if let PrimeCachesProgress::Started = progress { 206 PrimeCachesProgress::Started => prime_caches_progress.push(progress),
208 prime_caches_started = true; 207 PrimeCachesProgress::StartedOnCrate { .. } => {
208 match prime_caches_progress.last_mut() {
209 Some(last @ PrimeCachesProgress::StartedOnCrate { .. }) => {
210 // Coalesce subsequent update events.
211 *last = progress;
212 }
213 _ => prime_caches_progress.push(progress),
214 }
209 } 215 }
210 216 PrimeCachesProgress::Finished => prime_caches_progress.push(progress),
211 prime_caches_progress = Some(progress); 217 },
212 }
213 } 218 }
214 // Coalesce multiple task events into one loop turn 219 // Coalesce multiple task events into one loop turn
215 task = match self.task_pool.receiver.try_recv() { 220 task = match self.task_pool.receiver.try_recv() {
@@ -218,7 +223,7 @@ impl GlobalState {
218 }; 223 };
219 } 224 }
220 225
221 if let Some(progress) = prime_caches_progress { 226 for progress in prime_caches_progress {
222 let (state, message, fraction); 227 let (state, message, fraction);
223 match progress { 228 match progress {
224 PrimeCachesProgress::Started => { 229 PrimeCachesProgress::Started => {
@@ -238,11 +243,6 @@ impl GlobalState {
238 } 243 }
239 }; 244 };
240 245
241 if state != Progress::Begin && prime_caches_started {
242 // Progress indicator needs to be created first.
243 self.report_progress("indexing", Progress::Begin, None, Some(0.0));
244 }
245
246 self.report_progress("indexing", state, message, Some(fraction)); 246 self.report_progress("indexing", state, message, Some(fraction));
247 } 247 }
248 } 248 }